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
Is java platform independent?
What is the purpose of using java.lang.class class?
What are runtime exceptions?
What will be the initial value of an object reference which is defined as an instance variable?
Where can I find jdk in my computer?
What is the difference between JDBC 1.0 and JDBC 2.0?
what is the difference between process and thread? : Java thread
Can we overload the constructors?
What is the difference between stringbuffer and stringbuilder class?
What is package private scope in java?
What is the use of set in java?
What is 32 bit float?
How can I debug the Java security exceptions and AccessControlExceptions?
What function extracts specified characters from a string?
What are jee technologies?