Hi All
From various books it is clear that Constructors cannot have access modifiers (public,private, protected).
Yet, I was studying the Complete
Java 2 Certification book which gave the following code :
1 class Base {
2 public Base (
String s) {
3 //initialise Object using i
4 }
5 public Base (int i ) {
6 //initialise this object using i
7 }
8 }
9
10 class Derived extends Base {
11 public Derived (String s) {
12 //pass control to Base constructor at line 2
13 super(s);
14 }
15 public Derived (int i) {
16 //pass control to base constructor at line 5
17 super (i);
18 }
19 }
Can someone please explain to me how the constructors at lines 2 and 5 can have the "public" keywords attached to them ???
Thanks in Advance.