About Question enthuware.ocajp.i.v8.2.1371 :

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

Moderator: admin

Post Reply
Hawkward
Posts: 2
Joined: Thu Feb 11, 2016 6:22 pm
Contact:

About Question enthuware.ocajp.i.v8.2.1371 :

Post by Hawkward »

This question doesn't appear to have a correct answer:

Given the following declarations:
int a = 5, b = 7, k = 0;
Integer m = null;

and the following statements:
k = new Integer(a) + new Integer(b);  //1
k = new Integer(a) + b; //2
k = a + new Integer(b); //3
m = new Integer(a) + new Integer(b); //4

Executed independent of each other, what will be the value of k (for //1, //2, and //3) and m (for //4) after execution of each of these statements?

The correct answer is:

12
12
12
0

However, this answer isn't one of the choices. The test says that this is the correct answer:

12
12
12
12

But the last one can't be 12, as statement 4 doesn't affect the variable k, and the instructions say that each statement is independent of the others. Therefore, k would still be 0.

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

Re: About Question enthuware.ocajp.i.v8.2.1371 :

Post by admin »

The last one is asking you the value of m (not k).
If you like our products and services, please help us by posting your review here.

Hawkward
Posts: 2
Joined: Thu Feb 11, 2016 6:22 pm
Contact:

Re: About Question enthuware.ocajp.i.v8.2.1371 :

Post by Hawkward »

admin wrote:The last one is asking you the value of m (not k).
Oops :oops:

Post Reply

Who is online

Users browsing this forum: No registered users and 46 guests