Q71. Given the code fragment: 

How many times is 2 printed? 

A. Zero 

B. Once 

C. Twice 

D. Thrice 

E. It is not printed because compilation fails 

Answer:


Q72. 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:


Q73. ArrayList<Integer> list = new ArrayList<>(1); 

2. list.add(1001); 

3. list.add(1002); 

4. System.out.println(list.get(list.size())); 

What is the result? 

A. Compilation fails due to an error on line 1. 

B. An exception is thrown at run time due to error on line 3 

C. An exception is thrown at run time due to error on line 4 

D. 1002 

Answer:


Q74. 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:


Q75. Given: 

public class SampleClass { 

public static void main(String[] args) { 

AnotherSampleClass asc = new AnotherSampleClass(); SampleClass sc = new 

SampleClass(); 

sc = asc; 

System.out.println("sc: " + sc.getClass()); 

System.out.println("asc: " + asc.getClass()); 

}} 

class AnotherSampleClass extends SampleClass { 

What is the result? 

A. sc: class Object asc: class AnotherSampleClass 

B. sc: class SampleClass asc: class AnotherSampleClass 

C. sc: class AnotherSampleClass asc: class SampleClass 

D. sc: class AnotherSampleClass asc: class AnotherSampleClass 

Answer:


Q76. Given: 

Which two modifications are necessary to ensure that the class is being properly encapsulated? 

The class is poorly encapsulated. You need to change the circle class to compute and return the area instead. 

A. Remove the area field. 

B. Change the getArea( ) method as follows: public double getArea ( ) { return Match.PI * radius * radius; } 

C. Add the following method: public double getArea ( ) {area = Match.PI * radius * radius; } 

D. Change the cacess modifier of the SerRadius ( ) method to be protected. 

Answer: BD 


Q77. What is the result? 

A. Hello 

B. Default 

C. Compilation fails 

D. The program prints nothing 

E. An exception is thrown at run time 

Answer:


Q78. Which two packages are automatically imported into the java source file by the java compiler? 

A. Java.lang 

B. Java.awt 

C. Java.util 

D. Javax.net 

E. Java.* 

F. The package with no name 

Answer: AF 


Q79. Which is a valid abstract class? 

A. public abstract class Car { 

protected void accelerate(); 

B. public interface Car { 

protected abstract void accelerate(); 

C. public abstract class Car { 

protected final void accelerate(); 

D. public abstract class Car { 

protected abstract void accelerate(); 

E. public abstract class Car { 

protected abstract void accelerate() { 

//more car can do 

}} 

Answer:


Q80. Which three are advantages of the Java exception mechanism? 

A. Improves the program structure because the error handling code is separated from the 

normal program function 

B. Provides a set of standard exceptions that covers all the possible errors 

C. Improves the program structure because the programmer can choose where to handle 

exceptions 

D. Improves the program structure because exceptions must be handled in the method in 

which they occurred 

E. allows the creation of new exceptions that are tailored to the particular program being 

Answer: ACE