Олимпиадный тренинг

Задача . 37036


Задача

Темы:
This question refers to the following class:
public class IntObject
    {
        private int num;
        public IntObject() //default constructor
        { num = 0; }
        public IntObject(int n) //constructor
        { num = n; }
        public void increment() //increment by 1
        { num++; }
    }

Here is a client program that uses this class:
public class IntObjectTest
{
    public static IntObject someMethod(IntObject obj)
    {
        IntObject ans = obj;
        ans.increment();
        return ans;
    }
    public static void main(String[] args)
    {
        IntObject x = new IntObject(2);
        IntObject y = new IntObject(7);
        IntObject a = y;
        x = someMethod(y);
        a = someMethod(x);
    }
}

Just before exiting this program, what are the object values of x, y, and a, respectively?
(A) 9, 9, 9
(B) 2, 9, 9
(C) 2, 8, 9
(D) 3, 8, 9
(E) 7, 8, 9

time 1000 ms
memory 32 Mb
Правила оформления программ и список ошибок при автоматической проверке задач

Статистика успешных решений по компиляторам
Комментарий учителя