Oracle certification · Exam 1z0-808

1z0-808 Mock Exam Page 2

Java SE 8 Programmer I

Free 1z0-808 mock exam questions 11–20, each with the answer and an explanation.

20 questions · 33 minutes · free, no sign-up

Free 1z0-808 questions

11–20 of 70 free
Question 11 Choose 1

Consider following method

Which statement is true?

Show answerHide answer

Correct answer: B

This method can be used only in an interface.

Explanation

Given method is declared as default method so we can use it only inside an interface.
Hence option B is correct and option D is incorrect.
Option A is incorrect as it is valid method. Option C is incorrect as return type is void, which
means we can't return anything.

Question 12 Choose 1

Given:
public class FieldInit {
char c;
boolean b;
float f;
void printAll() {
System.out.println("c = " + c);
System.out.println("c = " + b);
System.out.println("c = " + f);
}
public static void main(String[] args) {
FieldInit f = new FieldInit();
f.printAll();
}
}
What is the result?

Show answerHide answer

Correct answer: D

c =
b = false
f = 0.0

Question 13 Choose 1

Given the following main method:

What is the result?

Show answerHide answer

Correct answer: D

5

Explanation

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

Question 14 Choose 1

Given the code fragment:
class Student {
int rollnumber;
String name;
List cources = new ArrayList();
// insert code here
public String toString() {
return rollnumber + " : " + name + " : " + cources;
}
}
And,
public class Test {
public static void main(String[] args) {
List cs = newArrayList();
cs.add("Java");
cs.add("C");
Student s = new Student(123,"Fred", cs);
System.out.println(s);
}
}
Which code fragment, when inserted at line // insert code here, enables class Test to print
123 : Fred : [Java, C]?

Show answerHide answer

Correct answer: C

Student(int i, String name, List cs) {
/* initialization code goes here */
}

Explanation

Incorrect:
Not A: Student has private access line: Student s = new Student(123,"Fred", cs);
Not D: Cannot be applied to given types. Line: Student s = new Student(123,"Fred", cs);

Question 15 Choose 1

Show answerHide answer

Correct answer: D

Option D

Question 16 Choose 1

Show answerHide answer

Correct answer: B

Option B

Question 17 Choose 1

Given:


What is the result?

Show answerHide answer

Correct answer: B

The code compiles, but does not execute.

Question 18 Choose 1

Given:

Which constructor initializes the variable x3?

Show answerHide answer

Correct answer: C

Only the no-argument constructor of class Z

Question 19 Choose 3

Given the following class:


And given the following main method, located in another class:
Which three lines, when inserted independently at line n1, cause the program to print a o
balance?

Show answerHide answer

Correct answer: D, G, H

acct.amount = 0;

acct.changeAmount(-acct.amount);

acct.changeAmount(-acct.getAmount());

Question 20 Choose 1

Given:

What is the result?

Show answerHide answer

Correct answer: C

A B C

Full mock exam

Sit the 1z0-808 exam before exam day

Full-length mocks with the same number of questions and the same time limit as the real 1z0-808 exam. Every attempt draws a new set of questions from the full bank, so you can keep going until you pass comfortably.

Get full 1z0-808 mock exam
  • 65questions per mock
  • 105 mintime limit
  • 236questions in the bank
  • Newmock on every attempt