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 Transient and volatile
Where are register variables stored?
Can we have multiple public classes in a java source file?
Is a char always 1 byte?
1) Find the Merge point of two linked lists. 2) Swap two bits of integer. 3) Reverse individual words of the sentence. 4) Reverse string without using temp string.
what is thread? What are the high-level thread states? Or what are the states associated in the thread? : Java thread
Explain why wait(), notify() and notifyall() methods are in object class rather than in thread class?
What are multiple inheritances? Is it supported by java?
What is a short in java?
can any one tell me when do u go for inheritance and polymorphism
Find the value of a specified element of the array arr[i] where 0 <= i <= n-1
What is audio clip interface? Name few methods of it ?