1.2k views
3 votes
public class Illustrate { private int x; private static int y; public static int count; public static int z; public Illustrate() { x = 1; } public Illustrate(int a) { x = a; } public void print() { System.out.println("x = " + x + ", y = " + y + ", count = " + count); } public static void incrementY() { y++; } } How many constructors are present in the class definition above?

User Worp
by
4.9k points

1 Answer

0 votes

Answer:

The answer for the given question is as follows:

There are two Constructors first one is the default Constructor and the second one Parameterized Constructor.

Explanation:

Constructor Definition:

Constructor is a special member function that task is to initialized as an object of its class.

To define constructor some rules can be given as:

1) The constructor name and class name must be the same.

2) In constructors, there is no return type, even void.

3) The constructor is automatically called when the class object is created.

There are 3 of constructor that can be given as :

a)Default constructor.

b) Parameterized constructor.

c)Copy constructor.

User Znik
by
5.7k points