Loading
anonymous inner class

Java Quick Notes

Refresh Your Java - Before Java Interview

We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....


Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet
Not Included Yet

Go to SiteMap

Q)  What is an anonymous Inner Class and a Innter class ?


Ans)

"An anonymous class is essentially a local class without a name."

As you will see from the sample program in this lesson, anonymous class definitions are often included as arguments to method calls.

Button buttonC = new Button("C");

buttonC.addMouseListener(new MouseListener()
{//begin class definition
//Instance initialize
{System.out.println(
"Anonymous class C name: " +
getClass().getName());}

As is the case for an object of a member class or a local class(an inner class) (discussed in previous lessons), an object of an anonymous class must be internally linked to an object of the enclosing class.

Thus, an anonymous class is truly an inner class, because an object of the anonymous class cannot exist in the absence of an object of the enclosing class.



Back to top

------------------------- We hope you got necessary Info On -----------------------------------------

anonymous inner class


anonymous inner class

-------------------------------------------------------------------------------------------------------



Face Book
Request for a Mock Interview/Training

Get a PDF

Face Book
Same look (Read) on any device, this is Ads free