October 17, 2000

Object Class

Question: Every class in Java is supposed to extend the Object class by default. In case a user class extends some other class (e.g., if myclassextends yourclass), then is it not multiple inheritance? Answer: Multiple inheritance is when one class inherits the behavior of two or more parent classes. Inheritance

Constructors and Member Variables

Question: After I have already declared an object, how can I call its constructor again to re-initialize its member variables? Answer: You can’t do that. C++ guarantees that for each object, a constructor is executed once and only once. A constructor’s address can’t be taken so you can’t even use

Static Methods

Question: What is the purpose of static methods in Java? Answer: Static methods can be invoked without an instance of an object. They provide the ability to execute methods in a manner similar to C functions. Utility functions that do not depend on the internal state of a class instance