Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Parent {
- public static void main(String[] m) {
- Parent childAsParent = new Child();
- System.out.println("Calling static method with declared Parent of type Child.");
- Binder.StaticMethod(childAsParent);
- new Binder().InstanceMethod(childAsParent);
- }
- }
- class Child extends Parent {
- }
- class Binder {
- public static void StaticMethod(Child d)
- {
- System.out.println("StaticMethod(Child d)");
- }
- public static void StaticMethod(Parent h)
- {
- System.out.println("StaticMethod(Parent h)");
- }
- public void InstanceMethod(Child d)
- {
- System.out.println("InstanceMethod(Child d)");
- }
- public void InstanceMethod(Parent h)
- {
- System.out.println("InstanceMethod(Parent h)");
- }
- }
- // Output:
- // Calling static method with declared Parent of type Child.
- // StaticMethod(Parent h)
- // InstanceMethod(Parent h)
Add Comment
Please, Sign In to add comment