Skip to content

Instantly share code, notes, and snippets.

@nicopaez
Created December 7, 2014 15:54
Show Gist options
  • Save nicopaez/65cf22f18eb0665b1f49 to your computer and use it in GitHub Desktop.
Save nicopaez/65cf22f18eb0665b1f49 to your computer and use it in GitHub Desktop.
ejercicio polimorfismo 1
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