1 /* 2 * Copyright (c) 2015, 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 interface InterfaceA { 25 public void Method1(); 26 public void Method2(); 27 } 28 29 class ClassA implements InterfaceA { 30 public void Method1() { 31 System.out.println("ClassA's Method1"); 32 } 33 public void Method2() { 34 System.out.println("ClassA's Method2"); 35 } 36 public void Method3() { 37 System.out.println("ClassA's Method3"); 38 } 39 public void Method4() { 40 System.out.println("ClassA's Method4"); 41 } 42 } 43 44 public class ClassB extends ClassA { 45 public void Method1() { 46 System.out.println("ClassB's Method1"); 47 } 48 public void Method3() { 49 System.out.println("ClassB's Method3"); 50 } 51 public static void main(String[] args) throws Exception { 52 ClassB classBObj = new ClassB(); 53 classBObj.Method1(); 54 classBObj.Method2(); 55 classBObj.Method3(); 56 classBObj.Method4(); 57 ClassA classAObj = new ClassA(); 58 classAObj.Method1(); 59 classAObj.Method2(); 60 classAObj.Method3(); 61 classAObj.Method4(); 62 } 63 }