관리 메뉴

IT.FARMER

JAVA Super Class , Overriding 본문

JAVA

JAVA Super Class , Overriding

아이티.파머 2010. 9. 8. 15:04
반응형

/*
 * $Id: SuperClassTest.java ,v 1.1 2010. 9. 8. 오후 2:10:43 smrscvs1 Exp $
 * created by    : ahn
 * creation-date : 2010. 9. 8.
 * =========================================================
 * Copyright (c) 2010 ManInSoft, Inc. All rights reserved.
 */

public class SuperClassTestA {
 @SuppressWarnings("unused")

 private String characterAName;
 
 public SuperClassTestA() {
  System.out.println("constructor A");
 }
 
 public void CharacterTestA() {
  characterAName = "parent Name Case 1";
  System.out.println(characterAName);
 }
 
 public void CharacterTestB(String name) {
  this.CharacterTestA();
  
  if(name.equals("")){
   name = "parent Name Case 2";
  }
  System.out.println(name);
  
 }
}




/*
 * $Id: SuperClassTestB.java ,v 1.1 2010. 9. 8. 오후 2:11:34 smrscvs1 Exp $
 * created by    : ahn
 * creation-date : 2010. 9. 8.
 * =========================================================
 * Copyright (c) 2010 ManInSoft, Inc. All rights reserved.
 */

public class SuperClassTestB extends SuperClassTestA{
 public SuperClassTestB() {
  // TODO Auto-generated constructor stub
  System.out.println("constructor B");
 }
 
 @Override
 public void CharacterTestA(){
  System.out.println("Child Class");
 }
 
 @Override
 public void CharacterTestB(String name){
  super.CharacterTestA();
  super.CharacterTestB(name);
 }
 
}




/*
 * $Id: SuperClassTest.java ,v 1.1 2010. 9. 8. 오후 2:48:11 smrscvs1 Exp $
 * created by    : ahn
 * creation-date : 2010. 9. 8.
 * =========================================================
 * Copyright (c) 2010 ManInSoft, Inc. All rights reserved.
 */

public class SuperClassTest {
 public static void main(String []ages){
  SuperClassTestB sup_C_B = new SuperClassTestB();
  
  SuperClassTestA sup_C_A = new SuperClassTestA();
  
  System.out.println("---------------------------------------------");
  sup_C_B.CharacterTestB("");
  System.out.println("---------------------------------------------");
  sup_C_B.CharacterTestA();
  
  System.out.println("#############################################");
  
  sup_C_A.CharacterTestA();
  System.out.println("---------------------------------------------");
  sup_C_A.CharacterTestB("");
 }
}

블라블라...

 

 

반응형