Given:
public class
Test {
double x, y;
Test() {
super();
}
}
The No arguments constructor Test() has "default" access modifier ( i.e with no access modifier ). True or False?
The Author's answer is False. He says: If the class is declared public, then the default constructor is implicitly given the access modifier public. If the class is declared protected, then the default constructor is implicitly given the access modifier protected and if the class is declared private, then the default constructor is implicitly given the access private.
I think the anwser for this one is True. I understand the default constructor is given only when the class contains no construction declaration, and then the constructor's modifier is implicitly given as class's modifier. In this question, a constructor is already given, and its access modifier is default meaning its accessibility is package level. So I think the anwser should be True. Am I right?
Besides, I wrote a subclass of Test class in another package. When I compile, I got error message: constructor Test() is not public in class pakgname.classname. I think if the Test() is public, subclass in another package should be able to access it.
Any coments for this question?