Advertisement
Arafat08BUET

Untitled

Sep 8th, 2012
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. abstract class MyDreamHouse{
  2.     abstract void makeLift(Object o);
  3.     void paintGate(Object o){
  4.         //your painting code goes here
  5.     }
  6. }
  7.  
  8. abstract class HulkHouse extends MyDreamHouse{
  9.  
  10.     void buildGarrage(Object o){
  11.  
  12.     }
  13.  
  14.     abstract void attachDoors(Object o);
  15.  
  16. }
  17.  
  18. class RealHouse extends HulkHouse{
  19.  
  20.     @Override
  21.     void attachDoors(Object o) {
  22.  
  23.     }
  24.  
  25.     @Override
  26.     void makeLift(Object o) {
  27.  
  28.     }
  29.  
  30. }
  31.  
  32. class abstractTester{
  33.     public static void main(String[] args){
  34.  
  35.         MyDreamHouse myHouse1; // its ok ! coz no instances is created!
  36.  
  37.         HulkHouse hulkHouse1; // its ok ! coz no instances is created!
  38.  
  39.         RealHouse realHouse1=new RealHouse();
  40.         RealHouse realHouse2=new RealHouse();
  41.  
  42.         myHouse1=realHouse1;
  43.         myHouse1.makeLift("Lift 1"); //calls its child realHouse1's method
  44.  
  45.         hulkHouse1=realHouse2;
  46.         hulkHouse1.makeLift("Lift 2");
  47.  
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement