Quality Testing

Quality is delighting customers

  • When a new object is created in a program a constructor gets invoked corresponding to the class.
  • The constructor is a method which has the same name as class name.
  • If a user doesn’t create a constructor implicitly a default constructor will be created.
  • The constructor can be overloaded.
  • If the user created a constructor with a parameter then he should create another constructor explicitly without a parameter. 

Views: 22

Reply to This

Replies to This Discussion

Most of the software testing company use  fferent type of languages for development and testing. So most of the OOP languages support Constructors.

A constructor is a special type of method of a class in OOP which is used for initialing an object of that type. It is an instance method that has the same name as the class, and it can be used to set the values of the members of an object

Types of constructors
Parameterized Constructors: Parameterized Constructors takes at least one argument and termed as parameterized constructors

class Example
{
Example :: Example(int a, int b)
{
x = a;
y = b;
}
}

Default constructors: If a constructor is not diclared for an instantiable class, Java compiler inserts a default constructor into the code

Copy constructors: Like C++, Copy Constructor is also supported by Java. But, unlike C++, default copy constructor doesn’t created by Java ,if you don’t write your own.Copy constructors helps in defining the actions performed by the compiler while copying class objects.

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2019   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service