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.


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.


Static method can be call object?

yes we can call a static method with object

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.


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.


Can you use multiple controllers on wii with mw3?

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


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.


What is the method of calling object's constructor in a function?

A constructor is not a function (it has no return value, not even void). As such you cannot call a constructor as you would a function. Constructors are always invoked automatically whenever an object of the class is instantiated. For example: struct S { // ...class has implicit default constructor }; static S s1; // instantiate an object of type S in static memory void f () { S s2; // instantiate an object of type S on the call stack } // s2 falls from scope here void g() { S* p = new S; // instantiate an object of type S on the heap // ... delete p; // release the object pointed to by p } // p falls from scope here int main() { f(); // call function f g(); // call function g } // s1 falls from scope here


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.

Trending Questions
What is the importance of analysis in the design of an algorithm? Why is batching of concrete by weight preferable to batching by volume? What output would you expect in the inverting amplifier if Ri were open? Which synthetic fibre goes into making velcro used in shoes? How does technical component and professional component each affects the reimbursement from the insurance carrier? What is the theory of conversion of AC to DC using 3-phase induction motor and DC shunt generator? Why is Hot water coming out of cold water line after installing a recirculating pump? The underwriters Laboratory logo on a product indicates that the product? What is true about the sum of the voltages across the components in a circuit compared to the voltage of the cell? What is the Algorithm for transpose of matrix in python? What are the items that used as a CSS Selector? What metal is harder than steel? What is the Java logical operators that has the highest order of preference? How much in is a pointer? How do you echo the return value of a function? What are the advantages of formal system development model over other software processes? What are the tool cutting characteristics needed to cut sheet metal? What represents a negative impact on technology recycling more or increased production of green house gases more technology available or increase in food production? Why would a high-level language not be an ideal tool for writing a program that directly accesses a printer port? What are two ways of improving your performance at work?