About Question enthuware.ocpjp.v21.2.3669 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
nnavlani
Posts: 8
Joined: Sat Aug 02, 2025 11:21 pm
Contact:

About Question enthuware.ocpjp.v21.2.3669 :

Post by nnavlani »

Integer r = i1+1000;
System.out.println(r); //This will print 3000
and
Integer r = i1 + Integer.valueOf(s1.replace("_", ""), 16); //This will throw an exception
System.out.println(r);
These two are right answers ?

Why is this being reported as one of the right answers ?
String s1 = "2_0";
Integer r = 100 + Integer(s1); //This will cause compilation failure
System.out.println(r);

Is there something wrong here?

admin
Site Admin
Posts: 10436
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

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

Post by admin »

There is nothing wrong. Wouldn't there be a compilation failure as the code say?
The problem statement is not asking you to pick the options that will compile or run. It just asking you to pick the right options. You have to check each option individually and see what it says. In this case, option 4 correctly identifies that this line will cause compilation failure and so it is a correct option.

Post Reply

Who is online

Users browsing this forum: No registered users and 84 guests