• Post Reply Bookmark Topic Watch Topic
  • New Topic

Private constructors and subtypes  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After finishing the second chapter of the SCJP6 study guide a question came to my mind:

If there's a class A with only private constructors and a class B which extends A, then this code will never compile because sooner or later a constructor of B has to (implicitly or explicitly) call the super constructor of A which however is private.

Is that correct?
 
Sheriff
Posts: 21136
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
100% correct. It's another way of making classes final (although it should never replace the final keyword).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!