Showing posts with label abstract class extends abstract class and interface implements interface. Show all posts
Showing posts with label abstract class extends abstract class and interface implements interface. Show all posts

Monday, November 5, 2012

Abstract class extends Abstract class and Interface extends Interface


Abstract class extends Abstract class

ComicsBook.java

abstract class ComicsBook {
     public abstract void book();
     public abstract void cartoons();
}

abstract class Marvel extends ComicsBook{ //Don’t have to implement any method of ComicsBook even though they are abstract

     public abstract void action();
}

UseAbstract.java
public class UseAbstract extends Marvel {//Have to implement all method of Marvel means also methods of ComicsBook

    
     @Override
     public void action() {
          // TODO Auto-generated method stub
         
     }

     @Override
     public void book() {
          // TODO Auto-generated method stub
         
     }

     @Override
     public void cartoons() {
          // TODO Auto-generated method stub
         
     };
}


Interface extends Interface 

Comics.java
public interface Comics {
     public void book();
     public void cartoons();
}


DCComics.java

public interface DCComics extends Comics{//Don’t have to implement any method of Comics even though they are abstract
     public void action();
}



UseInterface.java

public class UseInterface implements DCComics {//Have to implement all method of DCComics means also methods of Comics

    
     @Override
     public void action() {
          // TODO Auto-generated method stub
         
     }

     @Override
     public void book() {
          // TODO Auto-generated method stub
         
     }

     @Override
     public void cartoons() {
          // TODO Auto-generated method stub
         
     };
}