Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Why are inner classes required?

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


Please Help Members By Posting Answers For Below Questions

What do you mean by garbage collection used in java?

1069


What is printwriter in java?

957


Is java a super set of javascript?

1108


What is difference between calling start() and run() method of thread?

1134


Java.util.regex consists of which classes?

997


Is boolean a data type in java?

967


Difference between java and javascript

1103


How many types of parsers are there?

1019


Can private members of a base class are inheritable justify?

929


Where is core java used?

1017


How does thread synchronization occurs inside a monitor?

1103


What is lazy initialization in java?

1017


List the three steps for creating an object for a class?

971


Explain restrictions on using enum?

1082


How do I enable java in safari?

1041