Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

abstract class

 
varungoyal goyal
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can we declare a constructor of abstract class in any case.
thanks
 
Kia Phia Ben
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi varungoyal goyal
I think you can create constructor of abstract class when you call it in constructor of subclass
 
Burkhard Hassel
Ranch Hand
Posts: 1274
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi varungoyal,

can we declare a constructor of abstract class in any case.
thanks



Why do you post this question in a forum?
You can test it yourself in a minute.

Anyway, the answer is yes. Every class - also abstract classes -
MUST have a constructor. If you don't provide one, the default constructor will be used.

Below an abstract class with a constructor, and a concrete class extending the abstract one:






Yours,
Bu.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic