48、Given the following class:
public class Sample{
long length;
public Sample(long l){ length = l; }
public static void main(String arg[]){
Sample s1, s2, s3;
s1 = new Sample(21L);
s2 = new Sample(21L);
s3 = s2;
long m = 21L;
}
}
Which expression returns true?
A. s1 == s2;
B. s2 == s3;
C. m == s1;
D. s1.equals(m).
(b)
题目:给出下面的类:
…
哪个表达式返回true。
前面已经叙述过==操作符和String的equals()方法的特点,另外==操作符两边的操作数必须是同一类型的(可以是父子类之间)才能编译通过。
49、Given the following expression about List.
List l = new List(6,true);
Which statements are ture?
A. The visible rows of the list is 6 unless otherwise constrained.
B. The maximum number of characters in a line will be 6.
C. The list allows users to make multiple selections
D. The list can be selected only one item.
(ac)
题目:给出下面有关List的表达式:
…
哪些叙述是对的。
A. 在没有其它的约束的条件下该列表将有6行可见。
B. 一行的最大字符数是6
C. 列表将允许用户多选。
D. 列表只能有一项被选中。
List组件的该构造方法的第一个参数的意思是它的初始显式行数,如果该值为0则显示4行,第二个参数是指定该组件是否可以多选,如果值为true则是可以多选,如果不指定则缺省是不能多选。
50、Given the following code:
class Person {
String name,department;
public void printValue(){
System.out.println("name is "+name);
System.out.println("department is "+department);
}
}
public class Teacher extends Person {
int salary;
public void printValue(){
// doing the same as in the parent method printValue()
// including print the value of name and department.
System.out.println("salary is "+salary);
}
}
Which expression can be added at the "doing the same as..." part of the method printValue()?
A. printValue();
B. this.printValue();
C. person.printValue();
D. super.printValue().
(d)
题目:给出下面的代码:
…
下面的哪些表达式可以加入printValue()方法的"doing the same as..."部分。
子类可以重写父类的方法,在子类的对应方法或其它方法中要调用被重写的方法需要在该方法前面加上”super.”进行调用,如果调用的是没有被重写的方法,则不需要加上super.进行调用,而直接写方法就可以。这里要指出的是java支持方法的递归调用,因此答案a和b在语法上是没有错误的,但是不符合题目代码中说明处的要求:即做和父类的方法中相同的事情??打印名字和部门,严格来说也可以选a和b。
① 凡本网注明稿件来源为"原创"的所有文字、图片和音视频稿件,版权均属本网所有。任何媒体、网站或个人转载、链接转贴或以其他方式复制发表时必须注明"稿件来源:我考网",违者本网将依法追究责任;
② 本网部分稿件来源于网络,任何单位或个人认为我考网发布的内容可能涉嫌侵犯其合法权益,应该及时向我考网书面反馈,并提供身份证明、权属证明及详细侵权情况证明,我考网在收到上述法律文件后,将会尽快移除被控侵权内容。