Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- abstract class MyDreamHouse{
- abstract void makeLift(Object o);
- void paintGate(Object o){
- //your painting code goes here
- }
- }
- abstract class HulkHouse extends MyDreamHouse{
- void buildGarrage(Object o){
- }
- abstract void attachDoors(Object o);
- }
- class RealHouse extends HulkHouse{
- @Override
- void attachDoors(Object o) {
- }
- @Override
- void makeLift(Object o) {
- }
- }
- class abstractTester{
- public static void main(String[] args){
- MyDreamHouse myHouse1; // its ok ! coz no instances is created!
- HulkHouse hulkHouse1; // its ok ! coz no instances is created!
- RealHouse realHouse1=new RealHouse();
- RealHouse realHouse2=new RealHouse();
- myHouse1=realHouse1;
- myHouse1.makeLift("Lift 1"); //calls its child realHouse1's method
- hulkHouse1=realHouse2;
- hulkHouse1.makeLift("Lift 2");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement