Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

private constructor in abstract classes  RSS feed

 
Minal Silimkar-Urankar
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried to create private constructor in abstract classes.
It is allowing.

What is the use of private condtructors in absract claases?
 
Kishore Kumar
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
abstract class can have a private constructor. But that class cannot be extended by another class. Instead add a static inner class inside the abstact class and extend that abstract class.



This is a small sample code.
 
Minal Silimkar-Urankar
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok.

I got how I can use abstract class with private constructor.
Where we will use this type of constructors?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!