单项选择题

Given the following class 
class MyNumber
{
   private int num = 5;
   public MyNumber(int num) { this.num = num; }
   public int getNum() { return num; }
   public void setNum(int num) { this.num = num; }
}
   What is output after the executation of following code? 
   MyNumber obj1 = new MyNumber();
   MyNumber obj2 = new MyNumber(10);
   obj2 = obj1;
   obj2.setNum(20);
   System.out.println(obj1.getNum() + “,” + obj2.getNum());

A.5, 20
B.5, 10
C.20,20
D.编译错误
热门 试题

问答题
问答题