Question: Need a fix, and explain code. Why can't b.size access Small? If size = 1 is public shouldn't it be able to be accesssed from

Need a fix, and explain code. Why can't b.size access Small? If size = 1 is public shouldn't it be able to be accesssed from outside the class?

public class Big { private Small s = new Small(); public class 

public class Big { private Small s = new Small(); public class Small { } public int size = 1; public static void main(String[] args) { Big b = new Big(); b.size; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!