package oopsConcept;
public class OverrideSuperWithoutImplementsOrExtends {
public static void main(String[] args) {
MyClass myCls = new MyClass(){
//Overrided using anynomus class
public void doSomething() {
System.out.println("Doing something in the Super class modified ..");
}
};
myCls.doSomething();
MyInterface myintrface = new MyInterface(){
//Overrided using anynomus class
public void doSomething() {
System.out.println("Doing something in the Super class modified ..");
}
};
myintrface.doSomething();
}
}
interface MyInterface {
public void doSomething();
}
class MyClass{
public void doSomething(){
System.out.println("Doing something in the Super class..");
}
}
No comments:
Post a Comment
Thanks for your comments/Suggestions.