1z0-808 Premium Bundle

1z0-808 Premium Bundle

Java SE 8 Programmer I Certification Exam

4.5 
(21585 ratings)
0 QuestionsPractice Tests
0 PDFPrint version
November 5, 2024Last update

Oracle 1z0-808 Free Practice Questions

Q1. Given: 

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:

Q2. Given the code fragment: 

What is the result? 

A. Element 0 Element 1 

B. Null element 0 Null element 1 

C. Null Null 

D. A NullPointerException is thrown at runtime. 

Answer:

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

Q4. Given: 

class Overloading { 

int x(double d) { 

System.out.println("one"); 

return 0; 

String x(double d) { 

System.out.println("two"); 

return null; 

double x(double d) { 

System.out.println("three"); 

return 0.0; 

public static void main(String[] args) { 

new Overloading().x(4.0); 

What is the result? 

A. One 

B. Two 

C. Three 

D. Compilation fails. 

Answer:

Q5. Given: 

Which code fragment should you use at line n1 to instantiate the dvd object successfully? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Q6. Given: 

Which option enables the code to compile? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer: C,D 

Q7. Which statement is true about the default constructor of a top-level class? 

A. It can take arguments. 

B. It has private access modifier in its declaration. 

C. It can be overloaded. 

D. The default constructor of a subclass always invokes the no-argument constructor of its superclass. 

Answer:

Explanation: In both Java and C#, a "default constructor" refers to a nullary constructor that is automatically generated by the compiler if no constructors have been defined for the class. The default constructor is also empty, meaning that it does nothing. A programmer-defined constructor that takes no parameters is also called a default constructor. 

Q8. Given: 

public class Test { 

public static void main(String[] args) { 

int day = 1; 

switch (day) { 

case "7": System.out.print("Uranus"); 

case "6": System.out.print("Saturn"); 

case "1": System.out.print("Mercury"); 

case "2": System.out.print("Venus"); 

case "3": System.out.print("Earth"); 

case "4": System.out.print("Mars"); 

case "5": System.out.print("Jupiter"); 

Which two modifications, made independently, enable the code to compile and run? 

A. Adding a break statement after each print statement 

B. Adding a default section within the switch code-block 

C. Changing the string literals in each case label to integer 

D. Changing the type of the variable day to String 

E. Arranging the case labels in ascending order 

Answer: A,C 

Explanation: The following will work fine: 

public class Test { 

public static void main(String[] args) { 

int day = 1; 

switch (day) { 

case 7: System.out.print("Uranus"); break; 

case 6: System.out.print("Saturn"); break; 

case 1: System.out.print("Mercury"); break; 

case 2: System.out.print("Venus"); break; 

case 3: System.out.print("Earth"); break; 

case 4: System.out.print("Mars"); break; 

case 5: System.out.print("Jupiter"); break; 

Q9. Given: 

What is the result? 

A. true true 

B. true false 

C. false true 

D. false false 

E. Compilation fails 

Answer:

Q10. Given: 

What is the output? 

A. 1Z0 

B. 1Z0-808 

C. An exception will be thrown. 

D. Compilation fails due to error at line 3. 

E. Compilation tails due to error at line 4. 

Answer:

Explanation: 

Option E is the correct answer. Code fails to compile because there is no method called concert in StringBuilder class. The concert method is in String class. Hence option E is correct Here we should have used append method of StringBuilder class, in that case option B would be correct. https://docs.oracle.com/javase/tutorial/java/data/buffers.html 

Q11. Given: 

What is the result? 

A. C B A 

B. C 

C. A B C 

D. Compilation fails at line n1 and line n2 

Answer:

Q12. Given the code fragment: 

// insert code here 

arr[0] = new int[3]; 

arr[0][0] = 1; 

arr[0][1] = 2; 

arr[0][2] = 3; 

arr[1] = new int[4]; 

arr[1][0] = 10; 

arr[1][1] = 20; 

arr[1][2] = 30; 

arr[1][3] = 40; 

Which two statements, when inserted independently at line // insert code here, enable the code to compile? 

A. int [] [] arr = null; 

B. int [] [] arr = new int [2]; 

C. int [] [] arr = new int [2] [ ]; 

D. int [] [] arr = new int [] [4]; 

E. int [] [] arr = new int [2] [0]; 

F. int [] [] arr = new int [0] [4]; 

Answer: C,E 

Q13. The protected modifier on a Field declaration within a public class means that the field ______________. 

A. Cannot be modified 

B. Can be read but not written from outside the class 

C. Can be read and written from this class and its subclasses only within the same package 

D. Can be read and written from this class and its subclasses defined in any package 

Answer:

Reference: 

http://beginnersbook.com/2013/05/java-access-modifiers/ 

Q14. What is the name of the Java concept that uses access modifiers to protect variables and hide them within a class? 

A. Encapsulation 

B. Inheritance 

C. Abstraction 

D. Instantiation 

E. Polymorphism 

Answer:

Q15. Given: 

What is the result? 

A. 1 

B. 1 

C. 2 

D. Compilation fails 

E. The loop executes infinite times 

Answer:

START 1z0-808 EXAM