Why are inner classes required?

Answers were Sorted based on User's Feedback



Why are inner classes required?..

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

Why are inner classes required?..

Answer / shubha patil

inner class is basically used for binding the one class into
another class.

Is This Answer Correct ?    0 Yes 1 No

Why are inner classes required?..

Answer / mohammad aleemuddin

Inner classes are mainly used to encapsulate the data

Is This Answer Correct ?    1 Yes 4 No

Post New Answer

More Core Java Interview Questions

What super () does in java?

0 Answers  


When is the garbage collection used in Java?

0 Answers   BirlaSoft,


What are the advantages of encapsulation in java?

0 Answers  


What is anagram in java?

0 Answers  


Suppose there is an Online shopping cart application having different objects like Cart, SelectionItem, Billing, COnfiguration, Authentication, Authorization, PersonalDetails etc. Out of this which one can be made a singleton pattern and why?

2 Answers   RBS,






What does a void function return?

0 Answers  


What is sortedmap in java?

0 Answers  


what is comparable and comparator interface?

0 Answers  


What is the arguement of main method?

1 Answers  


Difference between method overloading and method overriding in java ?

0 Answers  


How do you remove an object from an arraylist in java?

0 Answers  


What is the difference between dom and sax parser in java?

0 Answers  


Categories