Given: What is the result?
A. true:true
B. true:false
C. false:true
D. false:false
Given: What is the result?
A. 1
B. 1
C. 2
D. Compilation fails
E. The loop executes infinite times
Given the code fragment: What is the result?
A. Execution terminates in the first catch statement, and caught a RuntimeException is printed to the console.
B. Execution terminates In the second catch statement, and caught an Exception is printed to the console.
C. A runtime error is thrown in the thread "main".
D. Execution completes normally, and Ready to us?is printed to the console.
E. The code fails to compile because a throws keyword is required.
Given:
What is the result?
A. Null
B. Compilation fails
C. An exception is thrown at runtime
D. 0
Given:
class MarksOutOfBoundsException extends IndexOutOfBoundsException { }
public class GradingProcess {
void verify(int marks) throws IndexOutOfBoundsException {
if (marks > 100) {
throw new MarksOutOfBoundsException();
}
if (marks > 50) {
System.out.print("Pass");
} else {
System.out.print("Fail");
}
}
public static void main(String[] args) {
int marks = Integer.parseInt(args[2]);
try {
new GradingProcess().verify(marks));
} catch(Exception e) {
System.out.print(e.getClass());
}
}
}
And the command line invocation:
Java grading process 89 50 104
What is the result?
A. Pass
B. Fail
C. Class MarketOutOfBoundsException
D. Class IndexOutOfBoundsException
E. Class Exception
Given: Which statement is true?
A. Both p and s are accessible by obj.
B. Only s is accessible by obj.
C. Both r and s are accessible by obj.
D. p, r, and s are accessible by obj.
Which two items can legally be contained within a java class declaration?
A. An import statement
B. A field declaration
C. A package declaration
D. A method declaration
Given the code fragment:
What is the result?
A. A B C
B. A B C D E
C. A B D E
D. Compilation fails.
Given the code fragment: What is the result?
A. A NullPointerException is thrown at runtime.
B. [1, 2, 4]
C. [1, 2, 4, null ]
D. [1, 3, 4, null ]
E. [1, 3, 4 ]
F. Compilation fails.
Given the code fragment:
What is the result?
A. 2012-02-10 00:00
B. 2012-01-30
C. 2012-02-10
D. A DateTimeException is thrown at runtime.
Given the code fragment:
What is the result?
A. Compilation fails.
B. The program compiles, but it prints nothing.
C. HiHowAreYou removed
D. An UnsupportedOperationException is thrown at runtime.
Given the code fragment:
Which code fragment, when inserted at line n1, enables the App class to print Equal?
A. Option A
B. Option B
C. Option C
D. Option D
Given the code fragment:
What is the result?
A. Sum is 600
B. Compilation fails at line n1.
C. Compilation fails at line n2.
D. A ClassCastException is thrown at line n1.
E. A ClassCastException is thrown at line n2.
Given: Which statement is true?
A. The program executes and prints:
500.0
B. Commenting line 16 enables the program to print: Thank You!
500.0
C. Commenting line 13 enables the program to print: Thank You!
500.0
D. The program executes and prints: Thank You!
500.0