第9章Java继承多态与接口.pptxVIP

  • 3
  • 0
  • 约4.38千字
  • 约 44页
  • 2017-05-29 发布于重庆
  • 举报
第9章Java继承多态与接口

第9章 Java继承、多态与接口 ;本章学习重点:;9.1 继承与多态;;Java继承:创建子类;【例】应用继承性的实例。 class Student{ //自定义“学生”类 int stu_id; //定义属性:学生学号 void set_id(int id){ //定义方法:设置学号 stu_id=id; } void show_id(){ //定义方法:显示学号 System.out.println(the student ID is:+stu_id); } } class UniversityStudent extends Student{ //定义子类 int dep_number; //定义子类特有的属性变量 void set_dep(int dep_num){ //定义子类特有的方法 dep_number=dep_num; } void show_dep( ){ System.out.println(the dep_number is:+dep_number); } public static void main(String args[]){ UniversityStudent Lee=new UniversityStudent(); Lee.set_id(20070

文档评论(0)

1亿VIP精品文档

相关文档