Q1. Given:
public class Main {
public static void main(String[] args) {
try {
doSomething();
}
catch (SpecialException e) {
System.out.println(e);
}}
static void doSomething() {
int [] ages = new int[4];
ages[4] = 17;
doSomethingElse();
}
static void doSomethingElse() {
throw new SpecialException("Thrown at end of doSomething() method"); }
}
What is the output?
A. SpecialException: Thrown at end of doSomething() method
B. Error in thread "main" java.lang.
ArrayIndexOutOfBoundseror
C. Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
at Main.doSomething(Main.java:12)
at Main.main(Main.java:4)
D. SpecialException: Thrown at end of doSomething() method at
Main.doSomethingElse(Main.java:16)
at Main.doSomething(Main.java:13)
at Main.main(Main.java:4)
Answer: C
Q2. The catch clause argument is always of type__________.
A. Exception
B. Exception but NOT including RuntimeException
C. Throwable
D. RuntimeException
E. CheckedException
F. Error
Answer: C
Q3. Given:
Javac Jump.java
Java Jump crazy elephant is always
What is the result?
A. Lazy lion is jumping
B. Lion is always jumping
C. Crazy elephant is jumping
D. Elephant is always jumping
E. Compilation fails
Answer: B
Q4. Given:
What is the result?
A. 11, 21, 31, 11, 21, 31
B. 11, 21, 31, 12, 22, 32
C. 12, 22, 32, 12, 22, 32
D. 10, 20, 30, 10, 20, 30
Answer: D
Q5. What is result?
A. Successful
B. Unsuccessful
C. Compilation fails
D. An exception is thrown at runtime
Answer: C
Q6. Given the class definitions:
And the code fragment of the main() method,
What is the result?
A. Java
Java
Java
B. Java
Jeve
va
C. Java
Jeve
ve
D. Compilation fails
Answer: D
Q7. Given:
What is the result?
A. One
B. Two
C. Three
D. Compilation fails
Answer: C
Q8. 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
Q9. View the Exhibit.
public class Hat {
public int ID =0;
public String name = "hat";
public String size = "One Size Fit All";
public String color="";
public String getName() { return name; }
public void setName(String name) {
this.name = name;
}
}
Given
public class TestHat {
public static void main(String[] args) {
Hat blackCowboyHat = new Hat();
}
}
Which statement sets the name of the Hat instance?
A. blackCowboyHat.setName = "Cowboy Hat";
B. setName("Cowboy Hat");
C. Hat.setName("Cowboy Hat");
D. blackCowboyHat.setName("Cowboy Hat");
Answer: D
Q10. racle 1z0-803 : Practice Test
j = (3 * ((2+4) + 5));
System.out.println("i:"+ i + "\nj":+j);
What is the result?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: B
Q11. Given:
A. X XX
B. X Y X
C. Y Y X
D. Y YY
Answer: D
Q12. Given:
What is the reference type of myZ and what is the type of the object it references?
A. Reference type is Z; object type is Z.
B. Reference type is Y; object type is Y.
C. Reference type is Z; object type is Y.
D. Reference type is X; object type is Z.
Answer: C
Q13. A method is declared to take three arguments. A program calls this method and passes only two arguments. What is the results?
A. Compilation fails.
B. The third argument is given the value null.
C. The third argument is given the value void.
D. The third argument is given the value zero.
E. The third argument is given the appropriate falsy value for its declared type.
F. An exception occurs when the method attempts to access the third argument.
Answer: A
Q14. Given:
Class A { }
Class B { }
Interface X { }
Interface Y { }
Which two definitions of class C are valid?
A. Class C extends A implements X { }
B. Class C implements Y extends B { }
C. Class C extends A, B { }
D. Class C implements X, Y extends B { }
E. Class C extends B implements X, Y { }
Answer: AE
Q15. Given:
Which three lines will compile and output “right on!”?
A. Line 5
B. Line 6
C. Line 7
D. Line 8
E. Line 9
F. Line 10
Answer: CDF
Q16. What is the result?
A. 100 210
B. Compilation fails due to an error in line n1
C. Compilation fails due to an error at line n2
D. Compilation fails due to an error at line n3
Answer: C