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.
About Question enthuware.ocajp.i.v8.2.1371 :
Moderator: admin
-
- Posts: 2
- Joined: Thu Feb 11, 2016 6:22 pm
- Contact:
-
- Site Admin
- Posts: 10055
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1371 :
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.
-
- Posts: 2
- Joined: Thu Feb 11, 2016 6:22 pm
- Contact:
Re: About Question enthuware.ocajp.i.v8.2.1371 :
Oopsadmin wrote:The last one is asking you the value of m (not k).
Who is online
Users browsing this forum: No registered users and 46 guests