+ 1
The equals method() quiz has an error
there is a private access variable x in class A, however in the question, we have class A { private int x; } A a = new A(); a.x =5; //what ?! there will be try to access private property error
4 odpowiedzi
+ 3
I have looked thorough the class definition more deeply and noticed that it must be OK, cause the instances of type A, are created in the public static main method of same class A, so it could be valid:
class A {
private int x;
public static void main(String[] arts) {
A a = new A();
a.x = 5;
}
}
but anyway this detail was not clarified yet, until the lesson where it appears...
0
yes, you are right
0
private variables are access with in class only... and not allowed to access from outside of the class..
0
Basicaly here the variable x is private and accesed from within the main method of same class so x is not out of the scope.