Oracle certification · Exam 1z0-808

1z0-808 Mock Exam Page 7

Java SE 8 Programmer I

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

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

Free 1z0-808 questions

61–70 of 70 free
Question 61 Choose 1

Given the code fragment?
public class Test {
public static void main(String[] args) {
Test t = new Test();
int[] arr = new int[10];
arr = t.subArray(arr,0,2);
}
// insert code here
}
Which method can be inserted at line // insert code here to enable the code to compile?

Show answerHide answer

Correct answer: A

public int[] subArray(int[] src, int start, int end) {
return src;
}

Question 62 Choose 1

Given:

What is the result?

Show answerHide answer

Correct answer: C

An exception is thrown at runtime

Question 63 Choose 2

Given the code fragment

And given the requirements:
If the value of the qty variable is greater than or equal to 90, discount = 0.5
If the value of the qty variable is between 80 and 90, discount = 0.2
Which two code fragments can be independently placed at line n1 to meet the
requirements?


Show answerHide answer

Correct answer: A, C

Option A

Option C

Question 64 Choose 3

Given:
public class ComputeSum {
public int x;
public int y;
public int sum;
public ComputeSum (int nx, int ny) {
x = nx; y =ny;
updateSum();
}
public void setX(int nx) { x = nx; updateSum();}
public void setY(int ny) { x = ny; updateSum();}
void updateSum() { sum = x + y;}
}
This class needs to protect an invariant on the sum field.
Which three members must have the private access modifier to ensure that this invariant is
maintained?

Show answerHide answer

Correct answer: C, E, F

The sum field

The setX ( ) method

The setY ( ) method

Explanation

The sum field and the two methods (setX and SetY) that updates the sum
field.

Question 65 Choose 1

A method is declared to take three arguments. A program calls this method and passes
only two arguments. What is the results?

Show answerHide answer

Correct answer: A

Compilation fails.

Question 66 Choose 1

Given:
public class Test1 {
static void doubling (Integer ref, int pv) {
ref =20;
pv = 20;
}
public static void main(String[] args) {
Integer iObj = new Integer(10);
int iVar = 10;
doubling(iObj++, iVar++);
System.out.println(iObj+ ", "+iVar);
What is the result?

Show answerHide answer

Correct answer: A

11, 11

Explanation

The code doubling(iObj++, iVar++); increases both variables from to 10 to
11.

Question 67 Choose 1

Given:

And the commands:
Javac Test.java
Java Test 12345
What is the result?

Show answerHide answer

Correct answer: A

Number us : 12345

Question 68 Choose 1

Given:

And the commands:
Javac Jump.java
Java Jump crazy elephant is always
What is the result

Show answerHide answer

Correct answer: B

Lion is always jumping

Question 69 Choose 2

Given:
Class A { }
Class B { }
Interface X { }
Interface Y { }
Which two definitions of class C are valid?

Show answerHide answer

Correct answer: A, E

Class C extends A implements X { }

Class C extends B implements X, Y { }


Explanation

extends is for extending a class.
implements is for implementing an interface.
Java allows for a class to implement many interfaces.

Question 70 Choose 1

Which of the following will print current time?

Show answerHide answer

Correct answer: C

System.ouLprint(LocalTime.now());

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

That's the last free question

You've seen the free 30% (70 of 236 questions). Full access unlocks every question and full-length 1z0-808 mock exams (65 questions, 105 minutes), a different mock on every attempt.

Unlock full mock exam
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