answersLogoWhite

0

You can have any number of constructors for a class. All we need to do is implement constructor overloading.

Ex: let us say we want to create multiple constructor for a class Test

Public class Test {

Public Test() {

//code

}

Public Test(int vals) {

//code

}

Public Test(String val) {

//code

}

}

User Avatar

Wiki User

14y ago

What else can I help you with?

Continue Learning about Engineering

What is a constructor with value zero?

Constructors have no value, zero or otherwise. That is, constructors cannot return a value. This is because constructors are not functions in the sense you cannot call a constructor directly. Constructors are invoked in the background when you instantiate an object of the class, thus any return value would be lost in the background, and would therefore not be visible to the invokee.


Can you call a constructor from another if a class has multiple constructors?

Yes. All you need to do is to specify the correct number of arguments to invoke the correct constructor.


What are the applications of this pointer?

The this pointer is used to refer to the object that is foremost in the current scope. It has three primary purposes. First, a programmer uses this to refer to a member variable that has been shadowed by a function argument. Secondly, it is used to obtain a reference to itself, usually for the purpose of passing itself to another function or class. Finally, the this pointer can be used to call alternate constructors of the same object, usually as a means of reusing code and providing various constructors with default arguments.


Static method can be call object?

yes we can call a static method with object


How constructor called?

You cannot invoke a constructor explicitly. It will get invoked implicitly when you call the new keyword on the class to create an object of the class. Ex: private ClassExample obj = new ClassExample(); here this new keyword usage on the ClassExample class will invoke the constructor of this class and create an object of that class.

Related Questions

What is a constructor with value zero?

Constructors have no value, zero or otherwise. That is, constructors cannot return a value. This is because constructors are not functions in the sense you cannot call a constructor directly. Constructors are invoked in the background when you instantiate an object of the class, thus any return value would be lost in the background, and would therefore not be visible to the invokee.


Can you call a constructor from another if a class has multiple constructors?

Yes. All you need to do is to specify the correct number of arguments to invoke the correct constructor.


What do you call the combination of variables and functions into a single object in C plus plus?

A singleton.


Is CAll of duty classic on PS3 for single or multiple players?

yes it is for single player offline and multiplayer online if by classic you mean Call of Duty 3 see related link


What are the applications of the pointer?

The this pointer is used to refer to the object that is foremost in the current scope. It has three primary purposes. First, a programmer uses this to refer to a member variable that has been shadowed by a function argument. Secondly, it is used to obtain a reference to itself, usually for the purpose of passing itself to another function or class. Finally, the this pointer can be used to call alternate constructors of the same object, usually as a means of reusing code and providing various constructors with default arguments.


What type of delegate contains multiple?

A multicast delegate is a type of delegate that can reference and invoke multiple methods. This allows a single delegate instance to call multiple methods in a single invocation, making it useful for event handling where multiple subscribers need to respond to an event. In .NET, multicast delegates are represented by the Delegate class, which can combine multiple methods into a single delegate instance.


Can you use multiple controllers on wii with mw3?

No, Call of Duty: Modern Warfare 3 for Wii is single player.


What are the applications of this pointer?

The this pointer is used to refer to the object that is foremost in the current scope. It has three primary purposes. First, a programmer uses this to refer to a member variable that has been shadowed by a function argument. Secondly, it is used to obtain a reference to itself, usually for the purpose of passing itself to another function or class. Finally, the this pointer can be used to call alternate constructors of the same object, usually as a means of reusing code and providing various constructors with default arguments.


Is Skype social networking site or a virtual classroom?

On skype, you are able to message people of your choice, call a single person or multiple people, and even video chat one or multiple people.


Static method can be call object?

yes we can call a static method with object


What do you call the measurement of the gravitatonal force acting on an object?

You call that the "weight" of the object.


Can multiple IP PBX share multiple call processors?

Multiple IP PBX can share multiple call processors with the use of standard interface.