What is an anonymous class?



What is an anonymous class?..

Answer / sai

An anonymous class is a local class without a name. An
anonymous class is defined and instantiated in a single
succinct expression using the new operator.

Example:
class popcorn{
public void eat(){
syso("popcorn is sweet");
}
public void m1(){
syso("popcorm method");
}
class sample{
public static void main(String args[]){
popcorn p = new popcorn(){
public void eat(){
syso("popcorn is so hot");
}
};
p.eat();
p.m1();
}
}

Is This Answer Correct ?    17 Yes 3 No

Post New Answer

More Core Java Interview Questions

What is a null class?

0 Answers  


what is platform dependent translation and platform dependent programming language

2 Answers  


What is difference between arraylist and list in java?

0 Answers  


what is mean by String and StringBuffer? What is mean by Methooverriding and Overloading?

2 Answers   Satyam,


Differentiate between a constructor and a method? Can we mark constructors final?

0 Answers  






What are data types in oop?

0 Answers  


tell me some common

2 Answers   TCS,


What are three advantages of using functions?

0 Answers  


How do you make a thread in java?

0 Answers  


What is collection class in java?

0 Answers  


Difference between object instantiation and construction ?

0 Answers  


Difference between array and arraylist.

23 Answers   Arise Solution, Banca Sella, iFocus, NIC, Sai Softech, Solartis, TCS, Verizon,


Categories