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 is class variable java?
What is string data?
What is a boolean field?
What is immutable in java?
What is the generic function?
Give few examples of final classes defined in Java API?
Can we place the any object to key attribute of HashMap<key,value>?
How TreeMap sorts the objects inside it?? suppose if have include one employee object and one car object. On what basis it will sort?
What is byte code and why is it important to java’s use for internet programming?
What is the purpose of return statement?
How will you measure that int takes up only 32 bits in memory?
What is data type in computer?