1z0-808 Premium Bundle

1z0-808 Premium Bundle

Java SE 8 Programmer I Certification Exam

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

Oracle 1z0-808 Free Practice Questions

Q1. Given: 

What is the result? 

A. true:true 

B. true:false 

C. false:true 

D. false:false 

Answer:

Q2. Given: 

What is the result? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Q3. Given: 

Which constructor initializes the variable x3? 

A. Only the default constructor of class X 

B. Only the no-argument constructor of class Y 

C. Only the no-argument constructor of class Z 

D. Only the default constructor of object class 

Answer:

Q4. Given: 

What is the result? 

A. myStr: 9009, myNum: 9009 

B. myStr: 7007, myNum: 7007 

C. myStr: 7007, myNum: 9009 

D. Compilation fails 

Answer:

Q5. Which two statements are true for a two-dimensional array? 

A. It is implemented as an array of the specified element type. 

B. Using a row by column convention, each row of a two-dimensional array must be of the same size. 

C. At declaration time, the number of elements of the array in each dimension must be specified. 

D. All methods of the class Object may be invoked on the two-dimensional array. 

Answer: A,D 

Q6. Given: 

public class String1 { 

public static void main(String[] args) { 

String s = "123"; 

if (s.length() >2) 

s.concat("456"); 

for(int x = 0; x <3; x++) 

s += "x"; 

System.out.println(s); 

What is the result? 

A. 123 

B. 123xxx 

C. 123456 

D. 123456xxx 

E. Compilation fails 

Answer:

Explanation: 123xxx 

The if clause is not applied. 

Note: Syntax of if-statement: 

if ( Statement ) { 

Q7. Given: 

Which of the following is equivalent to the above code fragment? 

A. System.out.printLn(x>10?">,': "<":,'="); 

B. System.out.println(x>10? ">"?"<":"="); 

C. System.out.println(x>10?">":x<10?"<":"="); 

D. System.out.printLn(x>10?">"?,'<"?"="); 

E. None of the above 

Answer:

Explanation: 

Option A is incorrect as we can't use abstract with non abstract method, (here method has method body.) Option C is incorrect as when overriding method we can't use more restrictive access modifier, so trying to use private to override default access Level method causes a compile time error. Option D is incorrect as default methods (not methods with default access level) are allowed only in interfaces. Option E is incorrect as method all ready has void as return type, so we can't add int there. Option B is correct as we can use final there, since the method is non abstract 

https://docs.oracle.com/javase/tutorial/java/landl/polymorphism.html 

Q8. Given the code fragment: 

Which code fragment prints blue, cyan, ? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Q9. Given: 

What is the output? 

A. [21, 13, 11] 

B. [30] 

C. [] 

D. Compilation fails due to error at line 7 

E. Compilation tails due to error at line 10 

Answer:

Explanation: 

Option D is the correct answer. 

Code fails to compile as we can't use primitive for collections type, so in this code trying to 

use int at line 7, causes a compile error. We should have use wrapper. Integer there. So 

option D is correct. 

https://docs.oracle.eom/javase/8/docs/api/java/util/ArrayList.html 

Q10. Given the code fragment: int[] array = {I, 2, 3, 4, 5}; And given the requirements: 

Process all the elements of the array in the order of entry. 

Process all the elements of the array in the reverse order of entry. 

Process alternating elements of the array in the order of entry. 

Which two statements are true? 

A. Requirements 1, 2, and 3 can be implemented by using the enhanced for loop. 

B. Requirements 1, 2, and 3 can be implemented by using the standard for loop. 

C. Requirements 2 and 3 CANNOT be implemented by using the standard for loop. 

D. Requirement 1 can be implemented by using the enhanced for loop. 

E. Requirement 3 CANNOT be implemented by using either the enhanced for loop or the standard for loop. 

Answer: D,E 

Q11. Given: 

class Cake { 

int model; 

String flavor; 

Cake() { 

model = 0; 

flavor = "Unknown"; 

public class Test { 

public static void main(String[] args) { 

Cake c = new Cake(); 

bake1(c); 

System.out.println(c.model + " " + c.flavor); 

bake2(c); 

System.out.println(c.model + " " + c.flavor); 

public static Cake bake1(Cake c) { 

c.flavor = "Strawberry"; 

c.model = 1200; 

return c; 

public static void bake2(Cake c) { 

c.flavor = "Chocolate"; 

c.model = 1230; 

return; 

What is the result? 

A. 0 unknown 0 unknown 

B. 1200 Strawberry 1200 Strawberry 

C. 1200 Strawberry 1230 Chocolate 

D. Compilation fails 

Answer:

Explanation: 1200 Strawberry 1230 Chocolate 

Q12. Given: 

What is the result? 

A. The program prints nothing 

B. d 

C. A StringIndexOutOfBoundsException is thrown at runtime. 

D. AnArrayIndexOutOfBoundsException is thrown at runtime. 

E. A NullPointerException is thrown at runtime. 

Answer:

Q13. Given: 

public class App { // Insert code here System.out.print("Welcome to the world of Java"); } } 

Which two code fragments, when inserted independently at line // Insert code here, enable the program to execute and print the welcome message on the screen? 

A. static public void main (String [] args) { 

B. static void main (String [] args) { 

C. public static void Main (String [] args) { 

D. public static void main (String [] args) { 

E. public void main (String [] args) { 

Answer: A,D 

Explanation: 

Incorrect: 

Not B: No main class found. 

Not C: Main method not found 

not E: Main method is not static. 

Q14. Given the code fragment: 

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

A. Make the method at line n1 public. 

B. Make the method at line n2 public. 

C. Make the method at line n3 public. 

D. Make the method at line n3 protected. 

E. Make the method at line n4 public. 

Answer: C,D 

Q15. Given: 

What is the result? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

START 1z0-808 EXAM