一、代码如下
package www.wujianbotwo; class Door { int height= 200; int weight= 80; String material= "实木"; private void open() { // TODO Auto-generated method stub System.out.println("开门"); } public void close() { // TODO Auto-generated method stub System.out.println("关门"); } }
package www.wujianbotwo; public class SafeDoor extends Door { @Override //public void close() { // TODO Auto-generated method stub //super.close(); //} public void close() { // TODO Auto-generated method stub System.out.println("子类关闭"); } public void closeTwo() { // TODO Auto-generated method stub super.close(); } public void closeThre() { // TODO Auto-generated method stub this.close(); } public void lock() { // TODO Auto-generated method stub System.out.println("子类锁门"); } }
-generated method stub Door door= new Door(); //door.open(); System.out.println(door.hashCode()); SafeDoor sdoor= new SafeDoor(); //sdoor.open(); sdoor.lock(); sdoor.close(); sdoor.closeTwo(); sdoor.closeThre(); } }
时间: 2024-10-14 13:16:19