As it pertains to Visual Basic if a class contains more than

As it pertains to Visual Basic, if a class contains more than one constructor, describe how the computer determines the appropriate constructor. Provide an example to support your response.

Solution

VB.NET support the inclusion of initialization and termination code that runs when a new instance of the class is created and deallocated. However, the names and behavior of these methods differ dramatically.

A constructor in VB.NET is defined as a procedure that has the name New (rather than Initialize as in VB 6.0) and can accept arguments to allow clients to pass data into the instance to assist with initialization. Constructors do not return values and therefore are always declared as a Sub. The constructor can also be overloaded and accept varying arguments to promote polymorphic use of the class.

When the first instance of a class is constructed using the New operator, the run-time will initially attempt to find and execute the shared constructor (defined as Shared Sub New()) on the class. Note that shared constructors are not defined with the Public keyword, cannot accept arguments, and hence cannot be overloaded with another version of the shared constructor. In other words, the following code is illegal because it attempts to overload a shared constructor:
After dealing with the shared constructor, the runtime executes any virtual constructor (a constructor that is not shared), passing in the optional arguments, for the specific instance of the class. After that is completed, the instance is ready for use.

The properties exposed by the My.Computer object return information about the computer on which the application is deployed, as determined at run time. Typically, this data differs from what was available on the development computer.
Some members, such as the My.Computer.Audio object, are available only for non-server applications.

As it pertains to Visual Basic, if a class contains more than one constructor, describe how the computer determines the appropriate constructor. Provide an exam

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site