200+ câu trắc nghiệm Lập trình cho di động có đáp án - Phần 6

Output của chương trình sau là?javaclass box{int width;int height;int length;}class mainclass{public static void main(String args[]){box obj1 = new box();box obj2 = new box();obj1.height = 1;

9/19

Output của chương trình sau là?

class box

{

int width;

int height;

int length;

}

class mainclass

{

public static void main(String args[])

{

box obj1 = new box();

box obj2 = new box();

obj1.height = 1;

obj1.length = 2;

obj1.width = 1;

obj2 = obj1;

System.out.println(obj2.height);

}

}

Chọn một:

1

2

runtime error

Garbage value

Giải thích

Chọn đáp án A