Free 1z0-808 Questions for Oracle Java SE 8 Programmer I 1z0-808 Exam as PDF & Practice Test Engine
Given the code fragment:

What is the result?

What is the result?
Correct Answer: B
Vote an answer
Explanation: Only visible for ExamDiscuss members. You can sign-up / login (it's free).
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?
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?
Correct Answer: A,B,F
Vote an answer
Explanation: Only visible for ExamDiscuss members. You can sign-up / login (it's free).
Given the code fragment:
int b = 3;
if ( !(b > 3)) {
System.out.println("square");
}{
System.out.println("circle");
}
System.out.println("...");
What is the result?
int b = 3;
if ( !(b > 3)) {
System.out.println("square");
}{
System.out.println("circle");
}
System.out.println("...");
What is the result?
Correct Answer: D
Vote an answer
Given:

Which is true?

Which is true?
Correct Answer: E
Vote an answer
Explanation: Only visible for ExamDiscuss members. You can sign-up / login (it's free).
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?
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?
Correct Answer: B
Vote an answer
Given the code fragment:
float x = 22.00f % 3.00f;
int y = 22 % 3;
System.out.print(x + ", "+ y);
What is the result?
float x = 22.00f % 3.00f;
int y = 22 % 3;
System.out.print(x + ", "+ y);
What is the result?
Correct Answer: B
Vote an answer
Given:
public class Test {
public static void main(String[] args) {
int arr[] = new int[4];
arr[0] = 1;
arr[1] = 2;
arr[2] = 4;
arr[3] = 5;
int sum = 0;
try {
for (int pos = 0; pos <= 4; pos++) {
sum = sum + arr[pos];
}
} catch (Exception e) {
System.out.println("Invalid index");
}
System.out.println(sum);
}
}
What is the result?
public class Test {
public static void main(String[] args) {
int arr[] = new int[4];
arr[0] = 1;
arr[1] = 2;
arr[2] = 4;
arr[3] = 5;
int sum = 0;
try {
for (int pos = 0; pos <= 4; pos++) {
sum = sum + arr[pos];
}
} catch (Exception e) {
System.out.println("Invalid index");
}
System.out.println(sum);
}
}
What is the result?
Correct Answer: A
Vote an answer
Explanation: Only visible for ExamDiscuss members. You can sign-up / login (it's free).
Given the code fragment:

and the requirements of the application:
- It must display the menu.
- It must print the option selected.
- It must continue its execution till it reads `0'.
Which code fragment can be used to meet the requirements?


and the requirements of the application:
- It must display the menu.
- It must print the option selected.
- It must continue its execution till it reads `0'.
Which code fragment can be used to meet the requirements?

Correct Answer: C
Vote an answer
0
0
0
10





