单选题在J2EE中,对于简单属性的方法: public Color getColor(){…} 和public Void setColor(Color c){…} 假定color是类中的属性,在方法体内可以()A在getColor方法体内只能有一行代码:return color; 在setColor方法体内只能有一行代码: this.color=c;B在getColor方法体内只能有一行代码:return color; 在setColor方法体内一定有该行代码: this.color=c;但还可以有其他的
题目
单选题
在J2EE中,对于简单属性的方法: public Color getColor(){…} 和public Void setColor(Color c){…} 假定color是类中的属性,在方法体内可以()
A
在getColor方法体内只能有一行代码:return color; 在setColor方法体内只能有一行代码: this.color=c;
B
在getColor方法体内只能有一行代码:return color; 在setColor方法体内一定有该行代码: this.color=c;但还可以有其他的代码
C
在getColor方法体内一定有该行代码:return color; 但还可以有其他的代码, 在setColor方法体内只能有该行代码: this.color=c;
D
在getColor方法体内一定要有该行代码:return color; 但还可以有其他的代码,在setColor方法体内一定有该行代码: this.color=c;但还可以有其他的代码
相似考题