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...


What is the use of anonymous inner classes ?

Answers were Sorted based on User's Feedback



What is the use of anonymous inner classes ?..

Answer / harish

an anonymous class is a local class that has no name

Is This Answer Correct ?    72 Yes 13 No

What is the use of anonymous inner classes ?..

Answer / chandrarekha

anonymous classes help to declare a class and create an
instance of a class in the same step.

Is This Answer Correct ?    59 Yes 5 No

What is the use of anonymous inner classes ?..

Answer / sam e

The use of an anonymous inner class is to create a
non-reusable implementation of an abstract class or
interface. For example, a UI button that is Runnable can
implement its run method at the same place in code that it
is created.

Is This Answer Correct ?    20 Yes 3 No

What is the use of anonymous inner classes ?..

Answer / sumit bansal

Anonymous class exist till the method or block (In which it
is defined) runs. After that it vanishes so it help to use
the memory efficiently.

in your code if you want a particular class once and that
is also in the method/block use anonymous class.

it is the best of my knowledge. if you know more please
reply me.

Is This Answer Correct ?    20 Yes 5 No

What is the use of anonymous inner classes ?..

Answer / guest

Anonymous class helps in Eventhandling

Is This Answer Correct ?    22 Yes 11 No

What is the use of anonymous inner classes ?..

Answer / bindhu

We can declare an inner class within the body of a method
without naming it. These classes are known as anonymous
inner classes
Very useful for controlled access to the innards
of another class. and useful when we need one instance of a
special class.

Is This Answer Correct ?    11 Yes 6 No

What is the use of anonymous inner classes ?..

Answer / juzer

Anonymous Class is used When we have a small task to be done.
It is for using memory efficiently.

Is This Answer Correct ?    6 Yes 1 No

What is the use of anonymous inner classes ?..

Answer / ashokkumar

Anonymous classes

1.These are one type of inner class that having no mame.

2.The syntax will come like

class a
{
public void mymethod ();

}
class b
{
a obja = new a(){//the anonymous class starts here
public void mymethod (){ //have to implement the methods of
//class 'a'
return "here we are implementing mymethod of class 'a'"
}

}; //when finishing anonymous classes we have to put";"

}

3.Here the anonymous class is consider as a sub class of
class 'a'.We can access all the variables and methods of
super class 'a' through the anonymous block,except local
variables,including private variables.

4.Through anonymous classes we can create instance for
Interfaces.

Is This Answer Correct ?    19 Yes 16 No

What is the use of anonymous inner classes ?..

Answer / suneetha

The use of anonymous inner classes is to access the data of
outer class.Even private data also we can access.

button.addActionListerner(new ActionListener(){
public void actionPerformed(){}
});

here we are using anonymous class to implement
ActionListener interface.If at all we are using other class
that implements ActionListener interface and passing that
obj into

button.addActionListener(obj);

In this method we cant access the private variables of the
class that call button.addActionListener();

Is This Answer Correct ?    7 Yes 4 No

What is the use of anonymous inner classes ?..

Answer / reddy vatti

The use of anonymous inner classes is to access the data of
outer class.Even private data also we can access.

button.addActionListerner(new ActionListener(){
public void actionPerformed(){}
});

here we are using anonymous class to implement
ActionListener interface.If at all we are using other class
that implements ActionListener interface and passing that
obj into

button.addActionListener(obj);

In this method we cant access the private variables of the
class that call button.addActionListener();

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

Can you declare a private method as static?

0 Answers   TCS,


Which of the classes will have more memory allocated?

0 Answers  


When is the garbage collection used in Java?

0 Answers   BirlaSoft,


How many ways can we create the string object?

0 Answers  


Why java is call by value?

0 Answers  


Describe method overriding

0 Answers  


Linked List reverese program

2 Answers   Bally Technologies,


what is the diffrence between class and object?

5 Answers  


what is the output ? Math.floor(-2.1) a)2 b)-2 c)-3.0 d)0

4 Answers   Accenture,


What is the difference between static (class) method and instance method?

0 Answers  


can we write two same methods in outer class and innerclass.

1 Answers   3i Infotech,


Difference between String and String Buffer?

3 Answers  


Categories