1z0-808 Premium Bundle

1z0-808 Premium Bundle

Java SE 8 Programmer I Certification Exam

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

Oracle 1z0-808 Free Practice Questions

Q1. Given the code fragment: 

public static void main(String[] args) { 

int iArray[] = {65, 68, 69}; 

iArray[2] = iArray[0]; 

iArray[0] = iArray[1]; 

iArray[1] = iArray[2]; 

for (int element : iArray) { 

System.out.print(element + " "); 

A. 68, 65, 69 

B. 68, 65, 65 

C. 65, 68, 65 

D. 65, 68, 69 

E. Compilation fails 

Answer:

Q2. Given: 

What is the result? 

A. 200.0 : 100.0 

B. 400.0 : 200.0 

C. 400.0 : 100.0 

D. Compilation fails. 

Answer:

Q3. Given the code fragment: 

public class ForTest { 

public static void main(String[] args) { 

int[] array = {1, 2, 3}; 

for ( foo ) { 

Which three code fragments, when replaced individually for foo, enables the program to compile? 

A. int i : array 

B. int i = 0; i < 1; 

C. ; ; 

D. ; i < 1; i++ 

E. i = 0; i<1; 

Answer: A,B,C 

Q4. Given: 

public class X { 

static int i; 

int j; 

public static void main(String[] args) { 

X x1 = new X(); 

X x2 = new X(); 

x1.i = 3; 

x1.j = 4; 

x2.i = 5; 

x2.j = 6; 

System.out.println( 

x1.i + " "+ 

x1.j + " "+ 

x2.i + " "+ 

x2.j); 

What is the result? 

A. 3 4 5 6 

B. 3 4 3 6 

C. 5 4 5 6 

D. 3 6 4 6 

Answer:

Q5. Given: 

Which statement is true? 

A. Both p and s are accessible by obj. 

B. Only s is accessible by obj. 

C. Both r and s are accessible by obj. 

D. p, r, and s are accessible by obj. 

Answer:

Q6. Given: 

Which code fragment, when inserted at line 14, enables the code to print Mike Found? 

A. int f = ps.indexOf {new patient (“Mike”)}; 

B. int f = ps.indexOf (patient(“Mike”)); 

C. patient p = new Patient (“Mike”); int f = pas.indexOf(P) 

D. int f = ps.indexOf(p2); 

Answer:

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

Q8. Given: 

public class TestOperator { 

public static void main(String[] args) { 

int result = 30 -12 / (2*5)+1; 

System.out.print("Result = " + result); 

What is the result? 

A. Result = 2 

B. Result = 3 

C. Result = 28 

D. Result = 29 

E. Result = 30 

Answer:

Q9. Which two statements are true for a two-dimensional array of primitive data type? 

A. It cannot contain elements of different types. 

B. The length of each dimension must be the same. 

C. At the declaration time, the number of elements of the array in each dimension must be specified. 

D. All methods of the class object may be invoked on the two-dimensional array. 

Answer: C,D 

Explanation: http://stackoverflow.com/questions/12806739/is-an-array-a-primitive-type-or-an-object-or-something-else-entirely 

Q10. boolean log3 = ( 5.0 != 6.0) && ( 4 != 5); 

boolean log4 = (4 != 4) || (4 == 4); 

System.out.println("log3:"+ log3 + \nlog4" + log4); 

What is the result? 

A. log3:false log4:true 

B. log3:true log4:true 

C. log3:true log4:false 

D. log3:false log4:false 

Answer:

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

Q12. Given: 

What is the result? 

A. 3 4 5 6 

B. 3 4 3 6 

C. 5 4 5 6 

D. 3 6 4 6 

Answer:

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

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

Q15. Given: 

public class MyClass { 

public static void main(String[] args) { 

while (int ii = 0; ii < 2) { 

ii++; 

System.out.println("ii = " + ii); 

What is the result? 

A. ii = 1 ii = 2 

B. Compilation fails 

C. The program prints nothing 

D. The program goes into an infinite loop with no output 

E. The program goes to an infinite loop outputting: ii = 1 ii = 1 

Answer:

Explanation: The while statement is incorrect. It has the syntax of a for statement. 

The while statement continually executes a block of statements while a particular condition is true. Its syntax can be expressed as: 

while (expression) { statement(s) } The while statement evaluates expression, which must return a boolean value. If the expression evaluates to true, the while statement executes the statement(s) in the while block. The while statement continues testing the expression and executing its block until the expression evaluates to false. 

Reference: The while and do-while Statements 

START 1z0-808 EXAM