*Based on answer choices A-E, what is the code's output?
9. Given the following code, the output is __.
class Apple
{
int i;
Apple(int n) { i = n; }
}
class Sample
{
public static void main(String args[])
{
Apple a1 = new Apple(2);
System.out.println(a1.i);
a1.i++;
}
}
A. 5
B. 4
C. 3
D. 2
E. 1
Answer: D
Comments
Leave a comment