Ask Question
4 January, 19:38

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

+2
Answers (1)
  1. 4 January, 20:09
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers