Searching for "Constructors"

Q:

How many constructors can a class have?

A) 1 B) 2
C) 4 D) None of the above
 
Answer & Explanation Answer: D) None of the above

Explanation:

A class can have any number of constructors. If a class have more than one constructor, we call it as the constructor is overloaded.

Report Error

View Answer Report Error Discuss

Filed Under: Java
Job Role: Database Administration , IT Trainer

Q:

How are this() and super() used with constructors?

Answer

Constructors use this to refer to another constructor in the same class with a different parameter list.


Constructors use super to invoke the superclass's constructor. If a constructor uses super, it must use it in the first line; otherwise, the compiler will complain.

Report Error

View answer Workspace Report Error Discuss

Subject: Java

Q:

What is Constructors and Destructors?

Answer

CONSTRUCTOR : PHP allows developers to declare constructor methods for classes. Classes which have a constructor method call this method on each newly-created object, so it is suitable for any initialization that the object may need before it is used.

DESTRUCTORS : PHP 5 introduces a destructor concept similar to that of other object-oriented languages, such as C++. The destructor method will be called as soon as all references to a particular object are removed or when the object is explicitly destroyed or in any order in shutdown sequence.

Report Error

View answer Workspace Report Error Discuss

Subject: PHP