Hi, If a class has private no-arg constructors, those classes cannot be instantiated? True/ False "TRUE" If a class has private constructors, those classes can be subclassed, but the constructors defined in subclasses cannot invoke super constructors ?True/False "True" If a class has no_arg private constructors, but if it has other constructors which are private, then the subclass can instantiate the class with out any compiler error? True/false True I just want to know is my ideas clear. Also I would like to know what all the things we need know on AWT and events for exam. Is it necessary to learn each every method in every class. What we have to know on I/O and threads?
Arathi, your first statment is mostly correct, but I would say that "If a class has a private no-arg constructor, that class cannot be instantiated by any classes using the no_arg constructor." If there are other non-private constructors, those can be used to instantiate the class. here's a simple example:
Hope this helps Rob [ January 08, 2002: Message edited by: Rob Ross ]
Joined: Nov 20, 2001
Hope this helps Rob [ January 08, 2002: Message edited by: Rob Ross ][/QB]
The above code works fine. But if you subclass a class, then it gives compiler error. Am i right. Because the subclass will invoke super class constructor and since the super class constructor is private it gives compiler error. Are you getting what i am mentioning. In your code, the class is not subclassed. So it won't be problem when you compile p=new Private("String");