Answer Posted / qamrun nisa
when an inner class is defined it is a member of the outer
class in much the same way as other members like attributes,
methods and constructors. When we access private data
members of the outer class, the JDK compiler creates
package-access member functions in the outer class for the
inner class to access the private members. This leaves a
security hole.
In general we should avoid using inner classes. Use inner
class only when an inner class is only relevant in the
context of the outer class and/or inner class can be made
private so that only outer class can access it. Inner
classes are used primarily to implement helper classes like
Iterators, Comparators etc which are used in the
context of an outer class.
| Is This Answer Correct ? | 7 Yes | 0 No |
Post New Answer View All Answers
What do you mean by garbage collection used in java?
What is printwriter in java?
Is java a super set of javascript?
What is difference between calling start() and run() method of thread?
Java.util.regex consists of which classes?
Is boolean a data type in java?
Difference between java and javascript
How many types of parsers are there?
Can private members of a base class are inheritable justify?
Where is core java used?
How does thread synchronization occurs inside a monitor?
What is lazy initialization in java?
List the three steps for creating an object for a class?
Explain restrictions on using enum?
How do I enable java in safari?