Created
December 7, 2014 15:54
-
-
Save nicopaez/65cf22f18eb0665b1f49 to your computer and use it in GitHub Desktop.
ejercicio polimorfismo 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package polimorfismo; | |
class ClaseA implements M { | |
public String m1() { | |
return "ClaseA.m1"; | |
} | |
public String m2() { | |
return "ClaseA.m2"; | |
} | |
public static String m3() { | |
return "ClaseA.m3"; | |
} | |
} | |
class ClaseB extends ClaseA { | |
public String m1() { | |
return "ClaseB.m1"; | |
} | |
} | |
class ClaseC extends ClaseB { | |
public String m1() { | |
return super.m2(); | |
} | |
} | |
M uno = new ClaseA(); | |
ClaseA dos = new ClaseB(); | |
ClaseA tre = new ClaseC(); | |
System.out.println(uno.m1()); | |
System.out.println(uno.m2()); | |
System.out.println(dos.m1()); | |
System.out.println(dos.m2()); | |
System.out.println(tre.m1()); | |
System.out.println(tre.m2()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment