"Every class has constructor". Is the line right?
Does Object class has constructor?
Does abstract class has constructor?
If abstract class has a constructor, when its subclass is initialized, is the abstract class' constructor called? We know abstract can't be initialized.
Thanks,<br />Thiru<br />[SCJP,SCWCD,SCBCD]
The basic design of abstract class is in such a way that it can not be instantiated but it can be extended. Extending is different from instantiation. By extending, you are inheriting the basic class features, but when you instantiate, you are actually creating an object of that kind.
Let us be showered in the light of confusion!
class A {
}
class B extends A {
public static void main(String[] args) {
new B();
}
}
Thanks,<br />Thiru<br />[SCJP,SCWCD,SCBCD]
Originally posted by Paul Villangca:
The Class class has no constructor. But you don't need to know this.![]()
use the [CODE] tags - it makes it much easier for people to help you.
Originally posted by Alan Chong:
But I think a better solution is just put a do nothing no-args constructor in all the classes you design.
use the [CODE] tags - it makes it much easier for people to help you.
The Class class has no constructor. But you don't need to know this.
Instead Class objects are constructed automatically by the Java Virtual Machine as classes are loaded and by calls to the defineClass method in the class loader.
Originally posted by Paul Villangca:
the Class class has no public constructor
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |