public class Parent { public static void main(String[] args) { Parent p1 = new Child(); int a = p1.add(3, 5); System.out.println("a = " + a ); Child c1 = new Child(); float b = c1.add(2.1f, 3,5.3f); System.out.println("b= " + b ); } int add( int a, int b) { return a + b; } } class Child extends Parent{ float add (float a, int b, float c) { return a + b + c; } }
a = 8 b= 10.4