Create a class with one integer instance variable. Initialize the variable using:

  1. default constructor
  2. parameterized constructor

Views 10

Answer:


class Number {
    int a;

    public Number() {
        a = 0;
    }

    public Number(int x) {
        a = x;
    }
}

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Java Programming Language, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.