I have pasted the code, now my query is that in 1st class named "accesssp" I have added object and then written SOP then why cant I have output as value of B ?? b's access is private but I am fetching value in same class
I've done section BOLD which I don't understand.
class accesssp {
public int a=56;
private int b=5566;
public int c=58766;
accesssp sp2 = new accesssp();
System.out.println(b);
}
class accesssp1 extends accesssp{
public void accessd() {
System.out.println(a);
System.out.println(c);
}
}
public class Access_Spf {
public static void main(String[] args) {
accesssp1 sp1 = new accesssp1();
sp1.accessd();
}
}
I have pasted the code, now my query is that in 1st class named "accesssp" I have added object and then written SOP then why cant I have output as value of B ?? b's access is private but I am fetching value in same class
I've done section BOLD which I don't understand.
class accesssp {
public int a=56;
private int b=5566;
public int c=58766;
accesssp sp2 = new accesssp();
System.out.println(b);
}
class accesssp1 extends accesssp{
public void accessd() {
System.out.println(a);
System.out.println(c);
}
}
public class Access_Spf {
public static void main(String[] args) {
accesssp1 sp1 = new accesssp1();
sp1.accessd();
}
}