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 |
Hi Friends, can you give difference between extending thread class and implementing runnable interface.
What is the Concept of Encapsulation in OOPS
What is difference between classpath and path variables in java?
What is the size of an array?
Can final class have constructor?
What are synchronized methods and synchronized statements in java programming?
What is function declaration?
Can we print null in java?
What do you mean by hashing?
Can we iterate through collection using for loop?
What is fail fast in java?
i need example for java abstraction. where we use abstraction and why we need abstraction.