1st Six Weeks Flashcards
When drawing a program, what are the variables called?
STATE
Name the primitive data types.
byte, int, long, short, char, boolean, float, and double
When drawing a program, what are the methods called?
BEHAVIOR
How do you write a main method?
public static void main(String[] args){
What does a byte contain?
A byte contains numbers between -128 to 127. Ex: 76
What does an int contain?
An int contains numbers between -2,147,483,648 to 2,147,483,647. Ex: 838,382
What does a short contain?
A short contains numbers between -32,768 to 32,767. Ex: -16,392
What does a long contain?
A long contains numbers between -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Ex: 477,838,383
What does a boolean contain?
A boolean contains the values of true and false.
What does a double contain?
A double contains numbers with decimals. Ex: 10.8
What does a float contain?
A float contains numbers that are decimals. One must put a lower case f at the end to indicate that the variable is a float. Ex: 78.4f
What does a char contain?
A char contains any character, surrounded by single quotes. Ex: ‘%’
What does int stand for?
Integer
What does char stand for?
Character
How does one instantiate a reference type?
Ex: Puppy puppy1 = new Puppy();
How does a void method look like?
Ex: public void copper{
System.out.println(“Hi”);
}
How does one begin a driver program?
Ex: public class DogDriver{
What is a mutator method?
A mutator method is used to set a value of a private field. It follows a naming scheme prefixing the word “set” to the start of the method name.
Define an accessor method.
An accessor method is used to return the value of a private field. It follows a naming scheme prefixing the word “get” to the start of the method name.
What is a toString method?
The toString method returns a string that “textually represents” an object.
Write a value returning method.
public char symbol(){
return ‘^’;
}
What is a modifier?
A modifier is a keyword placed in a class, method or variable declaration that changes how it operates.
What is a variable?
Variables are “containers” for storing information.