What is anonymous class?

Answers were Sorted based on User's Feedback



What is anonymous class?..

Answer / niranjanravi

An Anonymous class is a class which is defined at run time
without having any name and it is instantiated and declared
at the same place.
Syntax:
new class classname(){}
new interface interfacename(){}
Keyword extends and implements are usedin this class.
It is always implicitly final.
It is never static or final.

Is This Answer Correct ?    3 Yes 0 No

What is anonymous class?..

Answer / rimjhim

it is a local inner class without any name.
it is instantiated at the time of declaration and must be
extended by a class or implemented by an interface.

new [class name](argument list){anonymous class body};

overridden functions can be declared in this calss and it
can have only one new method inside it.more than one can
not be called anywhere.
using dot operator we can call that new function.

Is This Answer Correct ?    2 Yes 1 No

Post New Answer

More Core Java Interview Questions

What is the meaning of immutable regarding string?

0 Answers  


How many types of variables are there?

0 Answers  


How many types of memory areas are allocated by jvm?

0 Answers  


They had given one progam final HashMap hm=new HashMap(); public void show() { hm.put("name",value); } in this prg here the final hashtable value can be changed in put method,its the prg run?

3 Answers   DNS, Wipro,


Can a class declared as private be accessed outside it’s package?

0 Answers  






How do I convert a string to an int in java?

0 Answers  


Which class cannot be a subclass in java?

0 Answers  


What is the dot operator?

0 Answers  


how and when compiler knows that the Java code throws the checked Exception.

2 Answers   HSBC,


Explain about method local inner classes or local inner classes in java?

0 Answers  


How do you sort in ascending order in java?

0 Answers  


How does singleton class work?

0 Answers  


Categories