Q1. public class DoBreak1 {
public static void main(String[] args) {
String[] table = {"aa", "bb", "cc", "dd"};
for (String ss: table) {
if ( "bb".equals(ss)) {
continue;
}
System.out.println(ss);
if ( "cc".equals(ss)) {
break;
}
}
}
}
What is the result?
A. aa
B. aa bb cc
C. cc dd
D. cc
E. Compilation fails.
Answer: A
Q2. Given:
What is the result?
Oracle 1z0-803 : Practice Test
A. 0 Done
B. First Exception Done
C. Second Exception
D. Done Third Exception
E. Third Exception
Answer: B
Q3. What is the result?
A. 3 false 1
B. 2 true 3
C. 2 false 3
D. 3 true 1
E. 3 false 3
F. 2 true 1
G. 2 false 1
Answer: D
Q4. Given:
class X {}
class Y { Y ( ) { } }
class Z { Z (int i ) { } }
Which class has a default constructor?
A. X only
B. Y only
C. Z only
D. X and Y
E. Y and Z
F. X and Z
G. X, Y and Z
Answer: A
Q5. Given the fragment:
What is the result?
A. 13480.0
B. 13480.02
C. Compilation fails
D. An exception is thrown at runtime
Answer: C
Q6. Which three are valid types for switch?
A. int
B. float
C. double
D. integer
E. String
F. Float
Answer: ADE
Q7. Given:
And the commands:
Javac Test.java
Java Test 12345
What is the result?
A. Number us : 12345
B. A NullPointerException is thrown at runtime
C. A NumberFormatException is thrown at runtime
D. AnArrayIndexOutOfBoundException is thrown at runtime.
Answer: A
Q8. Given:
What is true about the class Wow?
A. It compiles without error.
B. It does not compile because an abstract class cannot have private methods.
C. It does not compile because an abstract class cannot have instance variables.
D. It does not compile because an abstract class must have at least one abstract method.
E. It does not compile because an abstract class must have a constructor with no arguments.
Answer: A
Q9. What is the result when this program is executed?
A. Bob's Name: Bob
B. Bob's Name: Jian
C. Nothing prints
D. Bob’s name
Answer: B
Q10. 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
Answer: ABD