Examine the following code:
class MyClass { /*from w w w . j a v a 2 s . com*/ String myName; } class Main { public static void main(String args[]) { MyClass c = new MyClass(); c.myName = "Java"; System.out.println(c.myName); } }
Which of the following statements will be true if the variable myName
is defined as a private variable?.
c
If the variable myName
is defined as a private member, it won't be accessible from the class Main.
An attempt to do so will cause it to fail at compile time.
Because the code won't compile, it can't execute.