Reusing code with Object

Report a typo

Take a look at the following non-generic class:

class NonGenericClass {

    private Object val;

    public NonGenericClass(Object val) {
        this.val = val;
    }

    public Object get() {
        return val;
    }
}

And here is the instance of this class:

NonGenericClass instance = new NonGenericClass("Hello");

Now we want to get the string back. When will the code throw a runtime exception?

Select one option from the list
___

Create a free account to access the full topic