Answer to Question #183608 in Java | JSP | JSF for Tim

Question #183608

*Based on answer choices A-E, what is the code's output?


10. Given the following code, the output is __.


class Apple

{

int i;

Apple(int n) { i = n; }

}

class Sample

{

int j;

private Sample()

{

Apple a1 = new Apple(2);

a1.i++;

j = a1.i;

}

public static void main(String args[])

{

Sample s1 = new Sample();

System.out.println(s1.j);

}

}


A. 5

B. 4

C. 3

D. 2

E. 1


1
Expert's answer
2021-04-27T09:36:54-0400

Answer: C


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog