Final Exam (part 1) Flashcards
The compiler generates bytecode even if the program has syntax errors. T/F
False
Java was originally developed by a team led by James Gosling at Sun Microsystems. T/F
True
One byte has ____ bits.
8
The JDK command to compile a class in the file Text.java is _____.
javac Test.java
The command to compile a class in the file Test.java is ____.
javac Test.java
______ is a technical definition of the language that includes the syntax and semantics of the java programming language.
Java JDK
The extension name of a java source code file is _____.
.java
A block is enclosed inside _____.
braces
To assign a double variable d to a float variable x, you write ______.
x = (float)d;
-25 % 5 is _____.
0
To improve readability and maintainability, you should declare _____ instead of using literal values such as 3.14159.
constants
To assign a value 1 to variable x, you write ______.
x = 1;
Which of the following assignment statements is illegal?
float f = -34;
int t = 23;
short s = 10;
float f = 34.0;
float f = 34.0;
Any assignment statement can be used as an assignment expression. T/F
True
If you attempt to add an int, a byte, a long, and a double, the result will be a _____ value.
double
System.exit(0) can be used to terminate the program. T/F
True
Suppose x = 10 and y = 10. What is x after evaluating the expression (y > 10) && (x– > 10)?
10
In Java, the word true is _____.
a Boolean literal
Which of the following expression is equivalent
to (x > 1)?
x >= 1
!(x <= 1)
!(x = 1)
!(x < 1)
!(x <= 1)
Assume x = 4, which of the following is true?
!(x == 4)
x != 4
x == 5
x != 5
x != 5
_______ are short-circuit operators.
&&
||
!
&&
||
Which of the following is a possible output for (int)(51 * Math.random())?
0
50
100
500
0
50
“smiles”.substring(1, 5) returns “mile”. T/F
true
An int variable can hold ____.
‘x’
120
120.0
‘x’
120