Hi all ,
I don't know exactly what will be output of this mail ...specially table ..
But this table is very good for
SCJP aspirants like me ...
How to look :
First of all there are two methods of accessing members of a class by other class :
1] Subclass(Inheritance) -> In this , the other class is the subclass of a class which has members .
class A{
int i;
}
class B extends A{
public static void main(
String[] s) {
System.out.println(i);
}
}
2] With same class reference -> In this , the other class is not a subclass of a class which has members . We are accessing members by the class reference which has members .
class C{
public static void main(String[] s) {
B b = new B();
System.out.println(b.i);
}
}
Now there are 4 types of members a class may have :
private, public, protected, default .
in pac -> in the same package .
out pac -> in other package .
Members in one class----Subclass(Inheritance)-----With same class reference
private-----------------
no-----------------------
no public------------------
yes----------------------
yes protected---------------in pac-------out pac------in pac--------out pac
------------------------
yes---------
yes---------
yes----------
no default
------------------------
yes---------
no----------
yes----------
no Any body please check & mention that the table is correct or not ...
thanks .