Java基础_abstract

1.使用abstract修饰且没有方法体的方法,称为抽象方法

特点:

(1)使用抽象abstract修饰的方法没有方法体,留给子类去实现

 (2)抽象类不能使用final和private以及static修饰

  (3)抽象方法必须定义在抽象类中或者接口中

  一般的习惯性把 abstract放在方法修饰符的最前面,明显就知道抽象方法

2.使用abstract修饰的类

特点

(1)不能创建实例即不能使用new一个抽象类

(2) 可以不包含抽象方法,但若有抽象方法就一定时抽象类

(3)若子类没有实现父类的所有的抽象方法,那么子类也作为抽象类。

(4)构造方法不能是private(私有)的类,否则不能有子类(创建子类是会先调用父类)

(5)抽象类中不能使用final修饰,因为必须有子类,抽象方法才能实现

(6)是不完整的类,作为基类,功能才能实现

抽象类必须要有子类,才能实现自己的功能

3.抽象类和普通类的区别

普通类有成员(方法,字段,构造器),抽象类都有

抽象类不能创建对象,抽象类中可以包含抽象方法

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Programming is an art. Although traditional art imitates life, programming simulates life. Every abstract concept in programming, and to a great extent in the fi eld of computer science, has its roots in our daily life. For example, humans and possibly all other living forms were multiprocessing long before the term entered into computer science lingo. Th erefore, any concept in programming can in fact be illustrated through examples from our dayto-day life. Such an approach not only enables the student to assimilate and internalize the concept presented in a programming situation but also provides a solid foundation for the very process of programming, namely, the simulation of the real world. Unfortunately, textbooks currently on the market do not exploit this fact through examples or meaningful discussions. Th us, for many students, an abstract concept remains abstract. Th is is especially true in the case of object-oriented programming. Th e “wow moment” one gets by seeing programming as a simulation of the real-world situation is never realized. Th is book on Java programming teaches object-oriented design and programming principles in a completely integrated and incremental fashion. Th is book allows the reader to experience the world we live in as object-oriented. From the very outset the reader will realize that everything in this world is an object. Every concept of object-oriented design is fi rst illustrated through real-life analogy. Corresponding Java language constructs are introduced in an integrated fashion to demonstrate the programming required to simulate the real-world situation. Instead of compartmentalizing all the object-oriented concepts into one chapter, this book takes an incremental approach. Th e pedagogy of this book mirrors the classroom style the author has developed over the years as a teacher of computer science. In particular, every programming concept is introduced through simple examples followed by short programming examples. Case studies at the end of each chapter illustrate various design issues as well as the usefulness of many new concepts encountered in that chapter. Java has emerged as the primary language for soft ware development. From a soft ware engineering perspective, object-oriented design has established itself as the industry standard. Th us, more and more teaching institutions are moving toward a CS1 course that teaches Java programming and object-oriented design principles. A common approach followed in many textbooks on the market is to introduce object-oriented concepts from the very beginning and ignore many traditional programming techniques completely. Th e objective of this book is to present object-oriented programming and design without compromising the training one needs on traditional programming constructs and structures.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值