Advertisement
Guest User

Untitled

a guest
May 25th, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1. class Star{
  2.    
  3.     public void doStuff(){
  4.         System.out.println("Twinking Star");
  5.     }
  6. }
  7. interface Universe{
  8.     public void doStuff();
  9. }
  10. class Sun extends Star implements Universe{
  11.     public void doStuff(){
  12.         System.out.println("Shining Sun");
  13.     }
  14. }
  15. public class Bob {
  16.     public static void main(String[] args) {
  17.         Sun obj2 = new Sun();
  18.         Star obj3 = obj2;
  19.         ((Sun)obj3).doStuff();
  20.         ((Star)obj2).doStuff();
  21.         ((Universe)obj2).doStuff();
  22.        
  23.     }
  24.    
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement