10 free sample questions from a bank of 206, with the correct answers and explanations. No signup required — start practising right now.
1Given: What is the result?
200.0 : 100.0
400.0 : 200.0
400.0 : 100.0
Compilation fails.
Answer: C
2Given the code fragment: What is the result?
Match 1
Match 2
No Match
A NullPointerException is thrown at runtime.
Answer: A
3Which two code fragments cause a compilation error? (Choose two.)
float flt = 100.00F;
float flt = (float) 1_11.00;
Float flt = 100.00;
double y1 = 203.22; float flt = y1;
int y2 = 100; float flt = (float) y2 ;
Answer:
4Given: What is the result?
A. B. C. D.
Answer:
5Which three statements are true about exception handling? (Choose three.)
Only unchecked exceptions can be rethrown.
All subclasses of the RuntimeException class are not recoverable.
The parameter in a catch block is of Throwable type.
All subclasses of the RuntimeException class must be caught or declared to be thrown.
All subclasses of the RuntimeException class are unchecked exceptions.
All subclasses of the Error class are not recoverable.
Answer:
6Given: And given the code fragment:
Book book1 = new EBook();
book1.readBook();
Which option enables the code to compile?
Option A
Option B
Option C
Option D
Answer: D
7Which two statements are true? (Choose two.)
Error class is unextendable.
Error class is extendable.
Error is a RuntimeException.
Error is an Exception.
Error is a Throwable.
Answer:
8Given: And given the commands: What is the result?
Java SE
Java EE
Compilation fails at line n1.
A NullPointerException is thrown at runtime.
Answer: A
9Given this class: And given this main method, located in another class: Which three pieces of code, when inserted independently, set the value of amount to 100? (Choose three.)
A. B. C. D. E. F.