1z0 808 pdf [Jun 2021]

Exam Code: exam 1z0 808 (Practice Exam Latest Test Questions VCE PDF)
Exam Name: Java SE 8 Programmer I
Certification Provider: Oracle
Free Today! Guaranteed Training- Pass exam 1z0 808 Exam.

Q51. Given the code fragment: 

What is the result? 

A. 100 

B. 101 

C. 102 

D. 103 

E. Compilation fails 

Answer:


Q52. Given: 

interface Pet { } 

class Dog implements Pet { } 

public class Beagle extends Dog{ } 

Which three are valid? 

A. Pet a = new Dog(); 

B. Pet b = new Pet(); 

C. Dog f = new Pet(); 

D. Dog d = new Beagle(); 

E. Pet e = new Beagle(); 

F. Beagle c = new Dog(); 

Answer: A,D,E 

Explanation: 

Incorrect: 

Not B, not C: Pet is abstact, cannot be instantiated. 

Not F: incompatible type. Required Beagle, found Dog. 


Q53. Given: 

public class Equal { 

public static void main(String[] args) { 

String str1 = "Java"; 

String[] str2 = {"J","a","v","a"}; 

String str3 = ""; 

for (String str : str2) { 

str3 = str3+str; 

boolean b1 = (str1 == str3); 

boolean b2 = (str1.equals(str3)); 

System.out.print(b1+", "+b2); 

What is the result? 

A. true, false 

B. false, true 

C. true, true 

D. false, false 

Answer:

Explanation: == strict equality. equals compare state, not identity. 


Q54. Consider following interface. 

Which of the following will create instance of Runnable type? 

A. Runnable run = 0 -> {System.out.println("Run");} 

B. Runnable run = 0 -> System.outprintlnfRun"); 

C. Runnable run = 0 > System.outprintlnfRun"); 

D. Runnable run = > System.ouLprintlnfRun"}; 

E. None of the above. 

Answer:

Explanation: 

Option A is the correct answer. 

To create we have used following method with LocalDate class; 

public static LocalDate of(intyear, int month, intdayOfMonth) 

Here we need to remember that month is not zero based so if you pass 1 for month, then 

month will be January. 

Then we have used period object of 1 day and add to date object which makes current date 

to next day, so final output is 2015-03-27. Hence option A is correct. 


Q55. Given the code fragment: 

What is the result? 

A. 10 : 10 

B. 5 : 5 

C. 5 : 10 

D. Compilation fails 

Answer:


Q56. Given the following code: 

What are the values of each element in intArr after this code has executed? 

A. 15, 60, 45, 90, 75 

B. 15, 90, 45, 90, 75 

C. 15, 30, 75, 60, 90 

D. 15, 30, 90, 60, 90 

E. 15, 4, 45, 60, 90 

Answer:


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


Q58. Given: 

Which option enables the code to compile? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer: C,D 


Q59. You are asked to develop a program for a shopping application, and you are given the following information: 

. The application must contain the classes Toy, EduToy, and consToy. The Toy class is the superclass of the other two classes. 

. The int caicuiatePrice (Toy t) method calculates the price of a toy. 

. The void printToy (Toy t) method prints the details of a toy. 

Which definition of the Toy class adds a valid layer of abstraction to the class hierarchy? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:


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