aspose file tools
The moose likes Beginning Java and the fly likes Private constructors and subtypes Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Private constructors and subtypes" Watch "Private constructors and subtypes" New topic
Author

Private constructors and subtypes

Sven Jacobs
Greenhorn

Joined: Feb 03, 2009
Posts: 3
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?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19216

100% correct. It's another way of making classes final (although it should never replace the final keyword).


SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://jrebel.com/download
 
subject: Private constructors and subtypes
 
Similar Threads
of a default constructor question required
Marcus Green Constructor Q doubt?
default constructor access
purpose of private constructor in abstract class
Constructor