Lecture19 - All constant values defined in an interface are implicitly public static and final interface Data1 cfw public final int x = 1 constant

Lecture19 - All constant values defined in an interface are...

This preview shows page 1 - 8 out of 34 pages.

Image of page 1
2 class Parent { int parentVariable; public void parentFunction() { System.out.println( "Parent Function" ); } public void overRideMe() { System.out.println( "In Parent" ); } } class Child extends Parent { public void overRideMe() { System.out.println( "In Child" ); } } class Inheritance { public static void main( String args[] ) { Parent Polymorphism = new Child(); Polymorphism.overRideMe(); Polymorphism.parentFunction(); } }
Image of page 2
3 class Parent { public void fancy() { whichOne(); } public void whichOne() { System.out.println( "Parent" ); } } class Child extends Parent { public void whichOne() { System.out.println( "Child" ); } } class VirtualFunctionsByDefault { public static void main( String args[] ) { Parent polymorphism = new Child(); polymorphism.fancy(); polymorphism = new Parent(); polymorphism.fancy(); } } Parent fancy() WhichOne() Child WhichOne()
Image of page 3