Given the code fragment:
What is the result?
A. 20
B. 25
C. 29
D. Compilation fails
E. AnArrayIndexOutOfBoundsException is thrown at runtime
Given the code fragment:
public class ForTest {
public static void main(String[] args) {
int[] array = {1, 2, 3};
for ( foo ) {
}
}
Which three code fragments, when replaced individually for foo, enables the program to compile?
A. int i : array
B. int i = 0; i < 1;
C. ; ;
D. ; i < 1; i++
E. i = 0; i<1;
Given the code fragment:
int b = 3;
if ( !(b > 3)) {
System.out.println("square ");
}{
System.out.println("circle ");
}
System.out.println("...");
What is the result?
A. square...
B. circle...
C. squarecircle...
D. Compilation fails.
Which three statements are benefits of encapsulation?
A. Allows a class implementation to change without changing t he clients
B. Protects confidential data from leaking out of the objects
C. Prevents code from causing exceptions
D. Enables the class implementation to protect its invariants
E. Permits classes to be combined into the same package
F. Enables multiple instances of the same class to be created safely
Given:
What is the result?
A. Null
B. Compilation fails
C. An exception is thrown at runtime
D. 0
Given the code fragment: System.out.println(2 + 4 * 9 - 3); //Line 21 System.out.println((2 + 4) * 9 - 3); // Line 22 System.out.println(2 + (4 * 9) - 3); // Line 23 System.out.println(2 + 4 * (9 - 3)); // Line 24 System.out.println((2 + 4 * 9) - 3); // Line 25 Which line of codes prints the highest number?
A. Line 21
B. Line 22
C. Line 23
D. Line 24
E. Line 25
Given:
A. ns = 50 S = 125 ns = 125 S = 125 ns = 100 S = 125
B. ns = 50 S = 125 ns = 125 S = 125 ns = 0 S = 125
C. ns = 50 S = 50 ns = 125 S = 125 ns = 100 S = 100
D. ns = 50 S = 50 ns = 125 S = 125 ns = 0 S = 125
Which usage represents a valid way of compiling java source file with the name "Main"?
A. javac Main.java
B. java Main.class
C. java Main.java
D. javac Main
E. java Main
Given the code fragment:
What is the result?
A. An exception is thrown at runtime.
B. 07-31-2014
C. 2014-07-31
D. 2014-09-30
Given:
What is the result?
A. c= b = false f = 0.0
B. c = null b = true f = 0.0
C. c = 0 b = false f = 0.0f
D. c = null b = false f = 0.0F