开发者

Java - Abstract Classes

开发者 https://www.devze.com 2022-12-24 03:24 出处:网络
If I declare class as abstract with no abstrac开发者_StackOverflowt methods declared in it, will it give a compilation error ?Two minutes with your compiler would\'ve told you the answer to that is \"

If I declare class as abstract with no abstrac开发者_StackOverflowt methods declared in it, will it give a compilation error ?


Two minutes with your compiler would've told you the answer to that is "no".


Not at all. An abstract class with no abstract methods can be used to signify a base class that is intended to be extended, but for which a concrete instance does not make sense.


It will not give compiler error. but it dosen't make any sense by using abstract keyword.


Abstract class declared with the keyword ‘abstract’, abstract class may or may not contain abstract method but if a Class has an abstract-method then the class is known as abstract class.

Abstract classes cannot be instantiated, but they can be sub-classed,

When an abstract class is sub-classed, the subclass usually provides implementations for all of the abstract methods in its parent class.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号