| 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
|
 |
 |
|
|
subject: Private constructors and subtypes
|
|
|