Can some one can tell me why java is giving 'attempting to assign weaker access privileges' compile error while compiling Abhishekchild.java ?
The two classes is :
public class Abhishek {
void asd()
{
System.out.println("hello");
}
static String a;
public static void main (String st[])
{
}
}
public class Abhishekchild extends Abhishek {
private void asd()
{
System.out.println("hello");
}
static String a;
public static void main (String st[])
{
}
}
In my opinion, java compiler is showing the error , as method asd has public visibility in Abhishek. java so
(i)it should be visble to all sub classes of Abhishek.java.
But if we override this function in Abhishekchild.java, and change the visibility to private then it will not be available for child of Abhishekchild.java. But these children are also children of Abhishek.java*, but this violates rule (i).*
So java shows a compilation error.