posted 21 years ago
Question
public class A
{
A()
{
}
}
1) The class A can be referenced outside the package in which it is defined.
2) The class A cannot be instantiated outside the package in which it is defined.
3) The class A cannot be extended outside the package in which it is defined.
4) The class A can be referenced, instantiated or extended anywhere.
5) The above code will cause a compiler error. The constructors of public class have to be public.
Answer is 1,2,3. Shouldn't it be 4, since the class is public. Constructors have the same access modifier as the class.
Thanks
Sharda