Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Marketing Strategy

Authors: O. C. Ferrell, Michael Hartline

6th edition

1285073045, 978-1285607139, 1285607139, 978-1285677316, 978-1285073040

More Books

Students also viewed these Programming questions