Ask Question
27 February, 07:39

public class Illustrate{private int x; private int y; public Illustrate () {x = 1; y = 2; }public Illustrate (int a) {x = a; }public void print () {System. out. println ("x = " + x + ", y = " + y); }public void incrementY () {y++; }}What does the default constructor do in the class definition above?1. Sets the value of x to 02. There is no default constructor. 3. Sets the value of x to 14. Sets the value of x to a

+1
Answers (1)
  1. 27 February, 10:20
    0
    The answer is "Option 3".

    Explanation:

    In the given java code a class "Illustrate" is defined inside the class two private integer variable is defined that is "x and y". Then a default constructor is defined which use these variable for assign values. Then we create the parameterized constructor in this constructor we an integer parameter and use variable x for the assign parameter value.

    In the class two function is defined that is "print and incrementY". The prints function print private variables value and incrementY function is increment the y variable value by 1. and other options are not correct that can be described as follows:

    In option 1, In x variable, we assign the value that is 0. In option 2, It is not correct, because there is a default constructor. In option 4, It is not correct, because this value is set in the parameterized constructor.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “public class Illustrate{private int x; private int y; public Illustrate () {x = 1; y = 2; }public Illustrate (int a) {x = a; }public void ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers