1z0-808 Premium Bundle

1z0-808 Premium Bundle

Java SE 8 Programmer I Certification Exam

4.5 
(240 ratings)
0 QuestionsPractice Tests
0 PDFPrint version
November 23, 2024Last update

Oracle 1z0-808 Free Practice Questions

Q1. Given the code fragment: 

public static void main(String[] args) { 

int iArray[] = {65, 68, 69}; 

iArray[2] = iArray[0]; 

iArray[0] = iArray[1]; 

iArray[1] = iArray[2]; 

for (int element : iArray) { 

System.out.print(element + " "); 

A. 68, 65, 69 

B. 68, 65, 65 

C. 65, 68, 65 

D. 65, 68, 69 

E. Compilation fails 

Answer:

Q2. Given the content of three files: 

Which statement is true? Which statement is true? 

A. Only the A.Java file compiles successfully. 

B. Only the B.java file compiles successfully. 

C. Only the C.java file compiles successfully. 

D. The A.Java and B.java files compile successfully. 

E. The B.java and C.java files compile successfully. 

F. The A.Java and C.java files compile successfully. 

Answer:

Explanation: In class B.Java doStuff() has access modifier with variable name which is not allowed. C.Java class name is different than file name. Only private classes can have different names than file names 

Q3. Given: 

Which option enables the code to compile? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer: C,D 

Q4. Given: 

What will be the output? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Q5. 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: A,B,D 

Q6. 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. 

Answer:

Q7. Given the following code for the classes MyException and Test: 

What is the result? 

A. A 

B. B 

C. Either A or B 

D. A B 

E. A compile time error occurs at line n1 

Answer:

Q8. Given the code fragment: 

What is the result? 

A. true true 

B. true false 

C. false false 

D. false true 

Answer:

Q9. Given the code fragment: 

int b = 3; 

if ( !(b > 3)) { 

System.out.println("square "); 

}{ 

System.out.println("circle "); 

System.out.println("..."); 

What is the result? 

A. square... 

B. circle... 

C. squarecircle... 

D. Compilation fails. 

Answer:

Q10. Which two are benefits of polymorphism? 

A. Faster code at runtime 

B. More efficient code at runtime 

C. More dynamic code at runtime 

D. More flexible and reusable code 

E. Code that is protected from extension by other classes 

Answer: C,D 

Q11. Given the code fragment 

int var1 = -5; 

int var2 = var1--; 

int var3 = 0; 

if (var2 < 0) { 

var3 = var2++; 

} else { 

var3 = --var2; 

System.out.println(var3); 

What is the result? 

A. – 6 

B. – 4 

C. – 5 

D. 5 

E. 4 

F. Compilation fails 

Answer:

Q12. Given: 

Which two code fragments are valid? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

E. Option E 

Answer: B,C 

Explanation: When an abstract class is subclassed, the subclass usually provides implementations for all of the abstract methods in its parent class (C). However, if it does not, then the subclass must also be declared abstract (B). Note: An abstract class is a class that is declared abstract—it may or may not include abstract methods. Abstract classes cannot be instantiated, but they can be subclassed. 

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:

Q14. Given: 

A. a, e 

i, o 

B. a, e 

o, o 

C. e, e 

I, o 

D. e, e 

o, o 

Answer:

Q15. Given the code fragment

Which code fragments, inserted independently, enable the code compile? 

A. t.fvar = 200; 

B. cvar = 400; 

C. fvar = 200; cvar = 400; 

D. this.fvar = 200; this.cvar = 400; 

E. t.fvar = 200; Test2.cvar = 400; 

F. this.fvar = 200; Test2.cvar = 400; 

Answer:

START 1z0-808 EXAM