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

2021 Apr 1z0-808 free practice test

Q81. Given: 

public class Test { 

static boolean bVar; 

public static void main(String[] args) { 

boolean bVar1 = true; 

int count =8; 

do { 

System.out.println("Hello Java! " +count); 

if (count >= 7) { 

bVar1 = false; 

} while (bVar != bVar1 && count > 4); 

count -= 2; 

What is the result? 

A. Hello Java! 8 Hello Java! 6 Hello Java! 4 

B. Hello Java! 8 Hello Java! 6 

C. Hello Java! 8 

D. Compilation fails 

Answer:

Explanation: Hello Java! 8 


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


Q83. Given the following class declarations: 

public abstract class Animal 

public interface Hunter 

public class Cat extends Animal implements Hunter 

public class Tiger extends Cat 

Which answer fails to compile? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

E. Option E 

Answer:

Explanation: Look at the right side of the declaration ArrayLIst() rather than ArrayList 


Q84. You are developing a banking module. You have developed a class named ccMask that has a maskcc method. 

Given the code fragment:

You must ensure that the maskcc method returns a string that hides all digits of the credit card number except the four last digits (and the hyphens that separate each group of four digits). 

Which two code fragments should you use at line n1, independently, to achieve this requirement? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer: B,C 


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


Improve 1z0-808 answers:

Q86. Which two actions will improve the encapsulation of a class? 

A. Changing the access modifier of a field from public to private 

B. Removing the public modifier from a class declaration 

C. Changing the return type of a method to void 

D. Returning a copy of the contents of an array or ArrayList instead of a direct reference 

Answer: A,D 

Reference: http://www.tutorialspoint.com/java/java_access_modifiers.htm 


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


Q88. Given the code fragment: 

What is the result if the integer aVar is 9? 

A. 10 Hello World! 

B. Hello Universe! 

C. Hello World! 

D. Compilation fails. 

Answer:


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


Q90. Given: 

public class MainMethod { 

void main() { 

System.out.println("one"); 

static void main(String args) { 

System.out.println("two"); 

public static void main(String[] args) { 

System.out.println("three"); 

void mina(Object[] args) { 

System.out.println("four"); 

What is printed out when the program is excuted? 

A. one 

B. two 

C. three 

D. four 

Answer: