Answer Posted / 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 View All Answers
What is parse method?
Why declare Main() method as a static in java ?
What is constructor and its types?
What is final modifier?
Does anyone still use java?
What is unicode full form?
How we create object in copy constructor?
What is the difference between Grid and Gridbaglayout?
Explain JMS in detail.
What are the Main functions of Java?
Are variables stored in ram?
Find the value of a specified element of the array arr[i] where 0 <= i <= n-1
Do I need to import java.lang package any time? Why?
How do you sort a list in java?
What is int short for?