1z0-808 Premium Bundle

1z0-808 Premium Bundle

Java SE 8 Programmer I Certification Exam

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

Oracle 1z0-808 Free Practice Questions

Q1. Which statement is true about Java byte code? 

A. It can run on any platform. 

B. It can run on any platform only if it was compiled for that platform. 

C. It can run on any platform that has the Java Runtime Environment. 

D. It can run on any platform that has a Java compiler. 

E. It can run on any platform only if that platform has both the Java Runtime Environment and a Java compiler. 

Answer:

Q2. Given the code fragment: 

Which statement is true? 

A. After line 8, three objects are eligible for garbage collection 

B. After line 8, two objects are eligible for garbage collection 

C. After line 8, one object is eligible for garbage collection 

D. After line 8, none of the objects are eligible for garbage collection 

Answer:

Q3. Given: 

What is the result? 

A. A B C D 

B. A C D 

C. A B C 

D. A B D 

E. A B D C 

Answer:

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

Q5. Given the code fragments: 

Which code fragment, when inserted at line ni, enables the code to print Hank? 

A. checkAge (iList, ( ) -> p. get Age ( ) > 40); 

B. checkAge(iList, Person p -> p.getAge( ) > 40); 

C. checkAge (iList, p -> p.getAge ( ) > 40); 

D. checkAge(iList, (Person p) -> { p.getAge() > 40; }); 

Answer:

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

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

Q8. Given: 

package p1; 

public interface DoInterface { 

void method1(int n1); // line n1 

package p3; 

import p1.DoInterface; 

public class DoClass implements DoInterface { 

public DoClass(int p1) { } 

public void method1(int p1) { } // line n2 

private void method2(int p1) { } // line n3 

public class Test { 

public static void main(String[] args) { 

DoInterface doi= new DoClass(100); // line n4 

doi.method1(100); 

doi.method2(100); 

Which change will enable the code to compile? 

A. Adding the public modifier to the declaration of method1 at line n1 

B. Removing the public modifier from the definition of method1 at line n2 

C. Changing the private modifier on the declaration of method 2 public at line n3 

D. Changing the line n4 DoClass doi = new DoClass ( ); 

Answer:

Explanation: Private members (both fields and methods) are only accessible inside the class they are declared or inside inner classes. private keyword is one of four access modifier provided by Java and its a most restrictive among all four e.g. public, default(package), protected and private. 

Read more: http://javarevisited.blogspot.com/2012/03/private-in-java-why-should-you-always.html#ixzz3Sh3mOc4D 

Q9. Given the code format: 

Which code fragment must be inserted at line 6 to enable the code to compile? 

A. DBConfiguration f; return f; 

B. Return DBConfiguration; 

C. Return new DBConfiguration; 

D. Retutn 0; 

Answer:

Q10. Give: 

What is the result? 

A. 1525 

B. 13 

C. Compilation fails 

D. An exception is thrown at runtime 

E. The program fails to execute due to runtime error 

Answer:

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

Q12. Given the code fragment: 

What is the result? 

A. A B C Work done 

B. A B C D Work done 

C. A Work done 

D. Compilation fails 

Answer:

Q13. Given: 

import java.util.*; 

public class Ref { 

public static void main(String[] args) { 

StringBuilder s1 = new StringBuilder("Hello Java!"); 

String s2 = s1.toString(); 

List<String> lst = new ArrayList<String>(); 

lst.add(s2); 

System.out.println(s1.getClass()); 

System.out.println(s2.getClass()); 

System.out.println(lst.getClass()); 

What is the result? 

A. class java.lang.String class java.lang.String class java.util.ArrayList 

B. class java.lang.Object class java.lang. Object class java.util.Collection 

C. class java.lang.StringBuilder class java.lang.String class java.util.ArrayList 

D. class java.lang.StringBuilder class java.lang.String class java.util.List 

Answer:

Explanation: class java.lang.StringBuilder class java.lang.String class java.util.ArrayList 

Q14. Given: 

What is the result? 

A. 10 20 30 40 

B. 0 0 30 40 

C. Compilation fails 

D. An exception is thrown at runtime 

Answer:

Q15. Given: 

A. Ym Xm2 

B. Ym Xm1 

C. Compilation fails 

D. A ClassCastException is thrown at runtime 

Answer:

START 1z0-808 EXAM