1z0-808 Premium Bundle

1z0-808 Premium Bundle

Java SE 8 Programmer I Certification Exam

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

Oracle 1z0-808 Free Practice Questions

Q1. Given the code fragment: 

Which option represents the state of the num array after successful completion of the outer loop? 

A. Option A 

B. Option B 

C. Option C 

D. Option D 

Answer:

Q2. Given: 

How many MarkList instances are created in memory at runtime? 

A. 1 

B. 2 

C. 3 

D. 4 

Answer:

Q3. Given: 

abstract class A1 { 

public abstract void m1(); 

public void m2() { System.out.println("Green"); } 

abstract class A2 extends A1 { 

public abstract void m3(); 

public void m1() { System.out.println("Cyan"); } 

public void m2() { System.out.println("Blue"); } 

public class A3 extends A2 { 

public void m1() { System.out.println("Yellow"); } 

public void m2() { System.out.println("Pink"); } 

public void m3() { System.out.println("Red"); } 

public static void main(String[] args) { 

A2 tp = new A3(); 

tp.m1(); 

tp.m2(); 

tp.m3(); 

What is the result? 

A. Yellow Pink Red 

B. Cyan Blue Red 

C. Cyan Green Red 

D. Compilation Fails 

Answer:

Q4. Given the for loop construct: 

for ( expr1 ; expr2 ; expr3 ) { 

statement; 

Which two statements are true? 

A. This is not the only valid for loop construct; there exits another form of for loop constructor. 

B. The expression expr1 is optional. it initializes the loop and is evaluated once, as the loop begin. 

C. When expr2 evaluates to false, the loop terminates. It is evaluated only after each iteration through the loop. 

D. The expression expr3 must be present. It is evaluated after each iteration through the loop. 

Answer: B,C 

Explanation: 

The for statement have this forms: 

for (init-stmt; condition; next-stmt) { 

body 

There are three clauses in the for statement. 

The init-stmt statement is done before the loop is started, usually to initialize an iteration 

variable. 

The condition expression is tested before each time the loop is done. The loop isn't 

executed if the boolean expression is false (the same as the while loop). 

The next-stmt statement is done after the body is executed. It typically increments an 

iteration variable. 

Q5. Which of the following will print current time? 

A. System.out.print(new LocalTime()-now0); 

B. System.out.print(new LocalTime()); 

C. System.ouLprint(LocalTime.now()); 

D. System.ouLprint(LocalTime.today()); 

E. None of the above. 

Answer:

Explanation: 

The LocalTime is an interface, so we can't use new keyword with them. So options A and C are incorrect. To get current time we can call now method on LocalTime interface. So option C is correct. Option D is incorrect as there is no method called today as in LocalTime interface 

https://docs.oracle.com/javase/tutorial/datetime/iso/datetime.html 

Q6. Given the code fragment: 

Which option can replace xxx to enable the code to print 135? 

A. int e = 0; e < = 4; e++ 

B. int e = 0; e < 5; e + = 2 

C. int e = 1; e < = 5; e + = 1 

D. int e = 1; e < 5; e+ =2 

Answer:

Q7. Given the code fragment: 

What is the result? 

A. Match 1 

B. Match 2 

C. No Match 

D. A NullPointerException is thrown at runtime. 

Answer:

Explanation: 

it will compare the string contents of the StringBuilder with string object. 

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

Q9. Given: 

The class is poorly encapsulated. You need to change the circle class to compute and return the area instead. 

Which two modifications are necessary to ensure that the class is being properly encapsulated? 

A. Remove the area field. 

B. Change the getArea( ) method as follows: 

public double getArea ( ) { return Match.PI * radius * radius; } 

C. Add the following method: 

public double getArea ( ) {area = Match.PI * radius * radius; } 

D. Change the cacess modifier of the SerRadius ( ) method to be protected. 

Answer: B,D 

Q10. View the exhibit: 

public class Student { 

public String name = ""; 

public int age = 0; 

public String major = "Undeclared"; 

public boolean fulltime = true; 

public void display() { 

System.out.println("Name: " + name + " Major: " + major); } 

public boolean isFullTime() { 

return fulltime; 

Which line of code initializes a student instance? 

A. Student student1; 

B. Student student1 = Student.new(); 

C. Student student1 = new Student(); 

D. Student student1 = Student(); 

Answer:

Q11. Given the code fragment: 

Which code fragment, when inserted at line 9, enables the code to print true? 

A. String str2 = str1; 

B. String str2 = new String (str1); 

C. String str2 = sb1. toString (); 

D. String str2 = "Duke"; 

Answer:

Q12. Given: 

What is the result? 

A. Compilation fails 

B. The code compiles, but does not execute. 

C. Paildrome 

D. Wow 

E. Mom 

Answer:

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

Q14. Given the following main method: 

What is the result? 

A. 5 4 3 2 1 0 

B. 5 4 3 2 1 

C. 4 2 1 

D. 5 

E. Nothing is printed 

Answer:

Explanation: 

Loop will run only once and after that num == 0 will break it After first cycle of the loop. 

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

START 1z0-808 EXAM