Anonymous Classes in Java
Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java
Program 1
interface MyButton
{
void click();
}
class TestAno
{
public static void main(String args[] )
{
MyButton M1=new MyButton()
{
public void click()
{
System.out.println("Color is red now");
}
};
MyButton M2=new MyButton(){
public void click()
{
System.out.println("Hello This is my photo");
}
};
M1.click();
M2.click();
}
}
// abstract class MyClass
// {
// abstract void display();
// }
// class TestAno
// {
// public static void main(String args[] )
// {
// MyClass M1=new MyClass(){
// void display()
// {
// System.out.println("Hello Friends How are you");
// }
// };
// MyClass M2=new MyClass(){
// void display()
// {
// System.out.println("Bye Bye Friends Meet Again........");
// }
// };
// M1.display();
// M2.display();
// }
// }
Your 15 seconds will encourage us to work even harder
Please share your happy experience on Google

