What is an anonymous class?
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 |
What's the difference between int and integer in java?
What are computer functions?
What is operator?
What happens when the main() isn't declared as static?
What does sizeof return?
What is a constructor, constructor overloading in java?
When throw keyword is used?
What are recursive functions? Give some examples?
0 Answers Axtria, ITC Indian Tobacco Company,
Can you explain the final method modifier?
What happens when you assigned a 'double' value to a 'String'?
What are the limitations of procedural programming approach?
If a multi threaded Java program has started numerous number of threads, at any point in time how to know which thread is currently executing/running ?
7 Answers Accenture, College School Exams Tests, iFlex, NIIT,