Oracle
1Z0-811 · Question #73
1Z0-811 Question #73: Real Exam Question with Answer & Explanation
Sign in or unlock 1Z0-811 to reveal the answer and full explanation for question #73. The question stem and answer options stay visible for context.
Object-Oriented Programming Principles
Question
Given the contents of the Test.java file:
class MyClass {
private int var1 = 100;
public int var2 = 200;
public void doCalc() {
var1 = 100 * 2;
var2 = 200 * 2;
}
}
public class Test {
public static void main(String[] args) {
MyClass x = new MyClass();
x.doCalc();
System.out.println (x.var1 + " " + x.var2); // line n2
}
}
What is the result?
Options
- A200 : 400
- BA compilation error occurs at line n1.
- CA compilation error occurs at line n2.
- D100 : 400
Unlock 1Z0-811 to see the answer
You've previewed enough free 1Z0-811 questions. Unlock 1Z0-811 for full answers, explanations, the timed quiz mode, progress tracking, and the master PDF. Question stem and options stay visible so you can still see what's on the exam.
Topics
#Access Modifiers#Private Keyword#Field Visibility#Encapsulation