Computer scienceProgramming languagesJavaCode organizationObject-oriented programmingClasses and objectsClasses and members

Multiple constructors

The Int class

Report a typo

Here's a simple wrapper class for values of the int type.

public class Int {

    int val = 1;

    public Int() {
        val = 2;
    }

    public Int(int val) {
        this();
    }
  
    public Int(int val1, int val2) {
        this(val1 + val2);
    }
}

What is the value of the field val in the created object?

Int myInt = new Int(3);
Select one option from the list
___

Create a free account to access the full topic