博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Java培训笔记十
阅读量:4027 次
发布时间:2019-05-24

本文共 435 字,大约阅读时间需要 1 分钟。

2009-7-25

 

抽象类:

(1)语法:abstract 类名:public abstract class  类名

  

(2)特点:<1>抽象类不能实例化

         <2>抽象类体里面应该包含抽象方法(方法声明)--<1>在返回值类型前被 abstract 修饰 <2>无方法体

         <3>继承了抽象父类的子类需对抽象父类中的抽象方法提供实现---重写

         <4>如果子类继承了抽象父类,且没有对父类中的抽象方法进行重写,那么该子类将变为抽象类

         <5>抽象类中不一定有抽象方法,但是包含了抽象方法的类就一定是抽象类

         例:       public abstract void  say();

(3)作用:<1>用于继承基础之上
         <2>给子类提供模板

(4)抽象类的形成条件:
   <1>类中至少由一个抽象方法
   <2>子类继承了父类的抽象方法,但是对于父类的抽象方法有一个没有实现,则子类也是抽象类
   <3>类实现了某个接口,但没有全部实现接口中的方法,则也为抽象类

(5)多态

(6)设计模式<2>:模板设计模式

转载地址:http://xyxbi.baihongyu.com/

你可能感兴趣的文章
机器学习实战之决策树(一)
查看>>
[LeetCode By Python] 2 Add Two Number
查看>>
python 中的 if __name__=='__main__' 作用
查看>>
机器学习实战之决策树二
查看>>
[LeetCode By Python]7 Reverse Integer
查看>>
[LeetCode By Python]9. Palindrome Number
查看>>
[leetCode By Python] 14. Longest Common Prefix
查看>>
[LeetCode By Python]107. Binary Tree Level Order Traversal II
查看>>
[LeetCode By Python]108. Convert Sorted Array to Binary Search Tree
查看>>
[leetCode By Python]111. Minimum Depth of Binary Tree
查看>>
[LeetCode By Python]118. Pascal's Triangle
查看>>
[LeetCode By Python]121. Best Time to Buy and Sell Stock
查看>>
[LeetCode By Python]122. Best Time to Buy and Sell Stock II
查看>>
[LeetCode By Python]125. Valid Palindrome
查看>>
[LeetCode By Python]136. Single Number
查看>>
[LeetCode By Python]167. Two Sum II - Input array is sorted
查看>>
[LeetCode BY Python]169. Majority Element
查看>>
[LeetCode By Python]172. Factorial Trailing Zeroes
查看>>
[LeetCode By MYSQL] Combine Two Tables
查看>>
python jieba分词模块的基本用法
查看>>