1z0-808 Premium Bundle

1z0-808 Premium Bundle

Java SE 8 Programmer I Certification Exam

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

Oracle 1z0-808 Free Practice Questions

Q1. Which statement is/are true? 

I. Default constructor only contains "super();" call. 

II. We can't use any access modifier with a constructor. 

III. A constructor should not have a return type. 

A. Only I. 

B. Only II. 

C. Only I and II. 

D. Only I and III. 

E. AIL 

Answer:

Explanation: 

Statement I is correct as the default constructor only contains super0 call 

Statement II is incorrect as we can use any access modifier with a constructor. 

Statement III is correct as constructor can't have return type, even void. 

So option D is correct. 

httpsy/docs.oracle.com/javase/tutorial/iava/javaOO/construaors.html 

Q2. Given: 

What is the result? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Q3. Given: 

What is the result? 

A. int main 1 

B. Object main 1 

C. String main 1 

D. Compilation fails 

E. An exception is thrown at runtime 

Answer:

Q4. Given the definitions of the MyString class and the Test class: 

What is the result? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Q5. Given: 

What is the result? 

A. 97 98 99 100 null null null 

B. 91 98 99 100 101 102 103 

C. Compilation rails. 

D. A NullPointerException is thrown at runtime. 

E. An ArraylndexOutOfBoundsException is thrown at runtime. 

Answer:

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

Q7. Given: 

What is the result? 

A. Good Day! Good Luck! 

B. Good Day! Good Day! 

C. Good Luck! Good Day! 

D. Good Luck! Good Luck! 

E. Compilation fails 

Answer:

Q8. Given the code fragment: 

What is the result? 

A. A B C 

B. A B C D E 

C. A B D E 

D. Compilation fails. 

Answer:

Q9. Given the code fragment: 

Which modification enables the code fragment to print TrueDone? 

A. Replace line 5 With String result = "true"; Replace line 7 with case "true": 

B. Replace line 5 with boolean opt = l; Replace line 7 with case 1= 

C. At line 9, remove the break statement. 

D. Remove the default section. 

Answer:

Q10. Given: 

class MarksOutOfBoundsException extends IndexOutOfBoundsException { } 

public class GradingProcess { 

void verify(int marks) throws IndexOutOfBoundsException { 

if (marks > 100) { 

throw new MarksOutOfBoundsException(); 

if (marks > 50) { 

System.out.print("Pass"); 

} else { 

System.out.print("Fail"); 

public static void main(String[] args) { 

int marks = Integer.parseInt(args[2]); 

try { 

new GradingProcess().verify(marks)); 

} catch(Exception e) { 

System.out.print(e.getClass()); } } } 

And the command line invocation: 

Java grading process 89 50 104 

What is the result? 

A. Pass 

B. Fail 

C. Class MarketOutOfBoundsException 

D. Class IndexOutOfBoundsException 

E. Class Exception 

Answer:

Explanation: The value 104 will cause a MarketOutOfBoundsException 

Q11. Given the code fragment: 

Which two modifications, when made independently, enable the code to print joe:true: 100.0? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

E. Option E 

Answer: A,C 

Q12. Given: 

What is the result? 

A. 2 4 6 8 10 12 

B. 2 4 6 8 10 12 14 

C. Compilation fails 

D. The program prints multiple of 2 infinite times 

E. The program prints nothing 

Answer:

Q13. Given: class Base { 

public static void main(String[] args) { 

System.out.println("Base " + args[2]); 

public class Sub extends Base{ 

public static void main(String[] args) { 

System.out.println("Overriden " + args[1]); 

And the commands: 

javac Sub.java 

java Sub 10 20 30 

What is the result? 

A. Base 30 

B. Overridden 20 

C. Overridden 20 Base 30 

D. Base 30 Overridden 20 

Answer:

Q14. Given the code fragment: 

Assume that the system date is June 20, 2014. What is the result? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Q15. Given the code fragment: 

Which three code fragments can be independently inserted at line nl to enable the code to print one? 

A. Byte x = 1; 

B. short x = 1; 

C. String x = "1"; 

D. Long x = 1; 

E. Double x = 1; 

F. Integer x = new Integer ("1"); 

Answer: A,B,F 

START 1z0-808 EXAM