is possible make abstract class child of normal class? please answer code or scenario if possible. this. class { }
abstract class b extends { }
is possible make abstract class child of normal class? please answer code or scenario if possible. this. class { }
abstract class b extends {
yes, entirely possible. being made abstract not prevent extending concrete class.
the general idea of abstract class provide common properties , behaviours (especially behaviours implemented individually in subclass). being made abstract prevent instantiation.
it still logical if want inherit properties concrete class abstract class though scenario rare.
a simple (or rather curde) example:
in honest opinion uncommon scenario. however, let me try give example relevance possible.
imagine having concrete class: person
class person { string name; //every person has name int age; //every person has age //constructors & other methods not shown }
and have abstract class: student
student class made abstract potential subclass in mind: part-time student
, full-time student
.
abstract class student { string name; //every student has name int age; //every student has age int grade; //every student has current grade (level of studies) //constructors & other methods not shown }
since every student
person
name
, age
, possible this:
abstract class student extends person { //name & age inherited int grade; //constructors & other methods not shown }
the above not best class design can have , argumentative can rearrange above classes such abstract class @ top of hierarchy , 1 simple example portraying idea abstract class may still inherit properties concrete class.
Comments
Post a Comment