Created
March 21, 2013 19:48
-
-
Save agarciadom/5216113 to your computer and use it in GitHub Desktop.
Small experiment for finding out the definition of the PCI mutation operator. I don't really see how downcasting in Java will change the behaviour in most cases: non-static methods are resolved using the actual type instead of the declared type, after all.
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
| class Parent { | |
| @Override | |
| public String toString() { | |
| return "Parent"; | |
| } | |
| } | |
| class Child extends Parent { | |
| @Override | |
| public String toString() { | |
| return "Child"; | |
| } | |
| } | |
| public class PCIMutationTest { | |
| public static void main(String[] args) { | |
| Child c = new Child(); | |
| Parent p = c; | |
| System.out.println(p.toString()); | |
| System.out.println(c.toString()); | |
| System.out.println(((Child)p).toString()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment