This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
A constructor can have any modifier. Its rules are same as using access modifiers for methods. there is no rule that the access modifier of the class and its constructor should be same. Class can have only public and default access modifiers while constructor can be protected public private and default.
[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
No, the classes' and constructors' access modifiers share no connection.
Usually you would mark your constructor as public, so any class can build an instance of it.
The best example not to do this though is the Singleton pattern.
In a Singleton you mark the constructor as private, so nobody but your own class can instantiate it.
To provide an instance to other classes, you would create a public static function that builds the instance on demand.
This allows you to control instances and impose restrictions, in the case of the Singleton you would only allow one instance.
JDBCSupport - An easy to use, light-weight JDBC framework -