What is a parameterized constructor

As discussed in the previous tutorial a default constructor is the one which takes no arguments. Similarly a parameterized constructor is the one to which you pass some arguments. For example look at this code below

class Test  {      Int x, y;            // Default constructor      public Test()      {      }            // Parameterized constructor      // It contains two arguments a and b whose values are assigned      // to x and y data members.      public Test(int a, int b)      {          x = a;          y = b;      }  }

You can have any number of parameterized constructors in your class but there can only be one default constructor.

Quick Links

E-Magazines

@

Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..

Ok

Login to Open ESchool OR Create your account    Login   SignUp