class A
{
public void display()
{
System.out.println("A");
}
}
the above program was saved as A.java
class B
{
public static void main(
String args[])
{
A a=new A();
a.display();
}
}
this program was saved as B.
java.
both the programs were compiled.
now when i run the second program B.java it gives the output "A".
now i change the "A.java" as follows
class A
{
private void display()
{
System.out.println("A");
}
}
after saving the program i compiled it.
now when i run B.java without compiling it again it gives the output "A".
since the display() method is of private scope it should give error!
am i right?
can anyone explain why it is giving the output imstead error.