Why are inner classes required?
Answers were Sorted based on User's Feedback
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 |
Answer / shubha patil
inner class is basically used for binding the one class into
another class.
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / mohammad aleemuddin
Inner classes are mainly used to encapsulate the data
| Is This Answer Correct ? | 1 Yes | 4 No |
What is a buffer in computer?
Can an interface extend another interface?
What is reflexive association?
how to fing linkedlist is circular or not?
Why does java doesnot support multiple inheritance?
what is the output??????? public class multireturn { public(int assign x ( int x) { if(4==x) { return 7; } else if (7=x+3) { return 6; } return 5; } }
How you can force the garbage collection?
Give a brief description of java socket programming?
Explain what do you mean by functional overloading in java?
What language is an assembler written in?
What is meant by distributed application? Why are we using that in our application?
Explain the use of shift operator in java. Can you give some examples?