Review Flashcards
What type does the Integer.parseInt method return?
Primitive integer (int)
What type does the Integer.valueOf method return?
Integer object
What does the ArrayList set( ) method do?
Sets an element at the index provided to the value provided
In Java, forward references to local variables are not allowed.
True
If a variable is declared in a switch statement case, it is available to all cases after it, but not before it.
True
Only a String, byte, short, int or char can be used as types of a switch variable.
False, the wrapper classes of these primitives can also be used.
You can start a literal value with an underscore.
False
A literal is a fixed value that doesn’t need further calculations in order for it to be assigned to any variable.
True
The char data type can be assigned a positive or a negative integer.
False, char is unsigned, it can only be assigned a positive integer value.
A top level class cannot be defined with the private or protected access modifier.
True
A concrete class cannot define an abstract method.
True
Local variables can be defined with access modifiers.
False
The append( ) method adds a String to the end of a String object.
False, the append( ) method belongs to StringBuilder.
Variables local to an if block are accessible to any else if or else blocks that follow it as well.
False
static public final void jump( ) { } is a valid method.
True
String static public jump( ) is a valid method
False, the return type is out of place.
public static void 2test ( ) { } is a valid method
False, you cannot start an identifier with a number.
Method arguments are the variables that appear in the definition of a method.
False, method arguments are the actual values that are passed to a method.
Static methods can access the nonstatic variables and methods of a class.
False.
To import the static method sort( ) from the Collections class, you would use the statement import static java.util.Collections;
False, static imports are only able to import static members, so import static java.util.Collections.*; or import static java.util.Collections.sort would be valid.