Computer scienceProgramming languagesJavaCode organizationObject-oriented programmingClasses and objectsClasses and members

Multiple constructors

Entanglement

Report a typo

The class SomeClass has four constructors:

class SomeClass {

    int val = 50;
    String str = "default";

    public SomeClass() {
       this(100);
    }

    public SomeClass(int val) {
        val = val;
    }

    public SomeClass(String str) {
        this();
        this.str = "some-value";
    }

    public SomeClass(int val, String str) {
        this(str);
    }
}

You've created an instance of this class:

SomeClass instance = new SomeClass(300, "another-value");

Find the correct values of fields for this instance.

Select one option from the list
___

Create a free account to access the full topic