Oracle certification · Exam 1z0-808

1z0-808 Mock Exam Page 6

Java SE 8 Programmer I

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

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

Free 1z0-808 questions

51–60 of 70 free
Question 51 Choose 1

Which statement best describes encapsulation?
Which statement best describes encapsulation?

Show answerHide answer

Correct answer: A

. Encapsulation ensures that classes can be designed so that only certain fields and
methods of an object are accessible from other objects.

Question 52 Choose 1

Given:
 
public class Test {
public static void main(String[] args) {
try {
String[] arr =new String[4];
arr[1] = "Unix";
arr[2] = "Linux";
arr[3] = "Solarios";
for (String var : arr) {
System.out.print(var + " ");
}
} catch(Exception e) {
System.out.print (e.getClass());
}
}
}
What is the result?

Show answerHide answer

Correct answer: B


BNull Unix Linux Solaris

Explanation

null Unix Linux Solarios
The first element, arr[0], has not been defined

Question 53 Choose 1

Given:

What would be the output, if it is executed as a program?

Show answerHide answer

Correct answer: C

name = null, pass = false

Explanation

Both name and pass variables are instance variables, and we haven't given them any
values, so they take their default values. For Boolean default value is false and for string
which is not a primitive type default is null So at line 7, null will printed as the value of the
variable name, and at line 8 false will be printed. Hence Option C is correct.
As explained above options A, B and D are incorrect.
Code compiles fine so option E is incorrect.
Reference:
https://docs.oracle.com/javaseAutorial/java/javaOOAariables.html

Question 54 Choose 1

Given:

What is the result?

Show answerHide answer

Correct answer: D

Compilation fails at line n2

Question 55 Choose 2

Given the following array:

Show answerHide answer

Correct answer: B, E

Option B

Option E

Explanation

All the remaining options have syntax errors

Question 56 Choose 1

Given the code fragment:

What is the result?

Show answerHide answer

Correct answer: C

 A B D E

Question 57 Choose 2

Which of the following can fill in the blank in this code to make it compile? (Select 2 option)
.)

Show answerHide answer

Correct answer: A, C

On line 1, fill in throws

On line 2, fill in throw new

Explanation

Option A and C are the correct answer.
In a method declaration, the keyword throws is used. So here at line 1 we have to use
option A.
To actually throw an exception, the keyword throw is used and a new exception is created,
so at line 2 we have to use throw and new keywords, which is option C. Finally it will look
like;
public void method() throws Exception {
throw new Exception0;
}
REFERENCE : httpsy/docs.oracle.com/javase/tutorial/essential/io/fileOps.html#exception
The correct answer is: On line 1, fill in throws. On line 2, fill in throw new

Question 58 Choose 1

Which statement is true about Java byte code?

Show answerHide answer

Correct answer: C

It can run on any platform that has the Java Runtime Environment.

Question 59 Choose 2

Given:
public class Test {
public static void main(String[] args) {
int day = 1;
switch (day) {
case "7": System.out.print("Uranus");
case "6": System.out.print("Saturn");
case "1": System.out.print("Mercury");
case "2": System.out.print("Venus");
case "3": System.out.print("Earth");
case "4": System.out.print("Mars");
case "5": System.out.print("Jupiter");
}
}
}
Which two modifications, made independently, enable the code to compile and run?

Show answerHide answer

Correct answer: A, C

Adding a break statement after each print statement

Changing the string literals in each case label to integer

Explanation

The following will work fine:
public class Test {
public static void main(String[] args) {
int day = 1;
switch (day) {
case 7: System.out.print("Uranus"); break;
case 6: System.out.print("Saturn"); break;
case 1: System.out.print("Mercury"); break;
case 2: System.out.print("Venus"); break;
case 3: System.out.print("Earth"); break;
case 4: System.out.print("Mars"); break;
case 5: System.out.print("Jupiter"); break;
}
}
}

Question 60 Choose 1

Given:
class Sports {
int num_players;
String name, ground_condition;
Sports(int np, String sname, String sground){
num_players = np;
name = sname;
ground_condition = sground;
}
}
class Cricket extends Sports {
int num_umpires;

int num_substitutes;
Which code fragment can be inserted at line //insert code here to enable the code to
compile?

Show answerHide answer

Correct answer: A

Cricket() {
super(11, "Cricket", "Condidtion OK");
num_umpires =3;
num_substitutes=2;
}

Explanation

Incorrect:
not C, not D: call to super must be the first statement in constructor.

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