How do you make multi-line comments?
/* */
A boolean variable that signals when
some condition exists in the program.
A flag
A while loop has what type of test?
Pre-test
What are the method modifiers?
Public and Static
What is a no-arg constructor?
A special method used to initialize an object in a default configuration.
When associated with the class header, they define the scope of the class.
When associated with a method, they define the scope of the method.
Curly Braces
Provide Logical Operators
||, &&, !
Given the following code, what type of loop is this?
int x = 5;
while(x > 0)
{
System.out.println("x is greater than 0");
x ++;
}
Infinite Loops
What is the variable that holds the value being passed into a
method?
Parameter
What is it called when two or more methods in a class may have the
same name as long as their parameter lists are different. (method’s signature)
Method Overloading
What is the escape sequence for newline?
\n
Give name1 and name2 are initialized. How do we check if they are truly the same name? (Write the code and tell me what it returns)
name1.equals(name2);
boolean value is returned.
What is needed in the parenthesis of a for loop?
Initialization, test, update
What is the statement
causes the method to end
execution and it returns a
value back to the
statement that called the
method
Return Statement
What is the key word not used when creating methods in a non-driver class?
static
What can the + operator do (hint: 2 things)?
Can be a concatenation operator with string and act as a regular operator with numbers.
What is the decision structure that lets the value of a variable or expression determine where the program will branch to?
Switch Statement
Say that a Random Object is created.
Create a random number between 5-10.
int number = random.nextInt(6) + 5;
Will there be compiler errors if there is widening conversion?
No
The data type of an argument must be the same as the variable declaration in the parentheses of the method declaration. True or false
True
int num;
What will this print?
int num = 0;
if(num >1){
System.out.println("a");
} num++;
else if(num >0){ System.out.println("b");}
num--;
else{ System.out.println("c");
}
System.out.println("d");
Error! You must immediately follow up with else if to continue the if-else-if statement. What would print if we got rid of num++ and num--;
What is something that can be used to notify the program to stop acquiring input.
Sentinel Value
When passing an object, what is passed?
The reference to the object is passed.
A variable associated with an object is called what?
Reference variable