1 /* 2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 import p2.D; 25 26 interface InterfaceA { Method1()27 public void Method1(); Method2()28 public void Method2(); 29 } 30 31 class ClassA implements InterfaceA { Method1()32 public void Method1() { 33 System.out.println("ClassA's Method1"); 34 } Method2()35 public void Method2() { 36 System.out.println("ClassA's Method2"); 37 } Method3()38 public void Method3() { 39 System.out.println("ClassA's Method3"); 40 } Method4()41 public void Method4() { 42 System.out.println("ClassA's Method4"); 43 } 44 } 45 46 public class ClassB extends ClassA { Method1()47 public void Method1() { 48 System.out.println("ClassB's Method1"); 49 } Method3()50 public void Method3() { 51 System.out.println("ClassB's Method3"); 52 } main(String[] args)53 public static void main(String[] args) throws Exception { 54 ClassB classBObj = new ClassB(); 55 classBObj.Method1(); 56 classBObj.Method2(); 57 classBObj.Method3(); 58 classBObj.Method4(); 59 ClassA classAObj = new ClassA(); 60 classAObj.Method1(); 61 classAObj.Method2(); 62 classAObj.Method3(); 63 classAObj.Method4(); 64 D classD = new D(); 65 D.loadD(); 66 } 67 } 68