Questions from Quiz 1 + Quiz 2 Flashcards
Which of the following is a constant, according to Java naming conventions?
read
MAX_VALUE
Test
!ReadInt
MAX_VALUE
Which of these data types requires the least amount of memory?
short
double
byte
float
byte
_____ are valid Java identifiers.
4+4
3ere
RE4$
int
RE4$
A Java interpreter is a program that translates Java source code into Java bytecode.
True
False
False
The compiler checks _______.
syntax errors
runtime errors
logic errors
Syntax Errors
________ is invoked to create an object.
The main method
A constructor
A method with a return type
A method with the void return type
A constructor
If you attempt to add an int, a byte, a long, and a float, the result will be a __________ value.
float
double
int
long
float
If the computer displays an error message while executing your program, the program contains a(n) __________.
run-time error
hidden error
logic error
syntax error
run-time error
What is the output for the following segment of code
intnum = 3, intNum = 1, intVal = 2, total = 0;
total += intnum++ * 5; System.out.print("intNum : " + intNum + " intVal : " + intVal ); System.out.println(" Total: " + total);
intNum : 1 intVal : 2
total : 15
because intnum++ in:
total += intnum++ * 5;
intnum ++ will use the current value of intnum in the operation then add 1 to it after the operation.
Analyze the following code:
public class Test {
private int t;
public static void main(String[] args) {
int x;
System.out.println(t);
}
}
Options:
The variable t is private and therefore cannot be accessed in the main method.
The program compiles and runs fine.
The variable x is not initialized and therefore causes errors.
The variable t is not initialized and therefore causes errors.
t is non-static and it cannot be referenced in a static context in the main method.
t is non-static and it cannot be referenced in a static context in the main method.