Page 1 of 1

About Question enthuware.ocpjp.v17.2.3669 :

Posted: Sun Dec 24, 2023 11:33 am
by Tester
Integer r = 100 + Integer(s1); //This will cause compilation failure
but explanation tells
1. the string "2_0" does not represent a valid int value and so, it will throw a NumberFormatException at runtime.
in first case "compilation failure" in the second "runtime". For me explanation looks right. Maybe its a good idea to correct the question?

Re: About Question enthuware.ocpjp.v17.2.3669 :

Posted: Sun Dec 24, 2023 8:42 pm
by admin
The question and the answer both are correct. You missed the first two sentences of the explanation :
Integer(s1) is invalid because there is no such method in the given code.

new Integer(s1) would have been valid constructor invocation but -
.....