Can we instantiate an abstract class?

后端 未结 16 1382
长情又很酷
长情又很酷 2020-11-22 07:43

During one of my interview, I was asked \"If we can instantiate an abstract class?\"

My reply was \"No. we can\'t\". But, interviewer told me \"Wrong, we can.\"

16条回答
  •  长情又很酷
    2020-11-22 08:17

    About Abstract Classes

    • Cannot create object of an abstract class
    • Can create variables (can behave like datatypes)
    • If a child can not override at least of one abstract method of the parent, then child also becomes abstract
    • Abstract classes are useless without child classes

    The purpose of an abstract class is to behave like a base. In inheritance hierarchy you will see abstract classes towards the top.

提交回复
热议问题