您的位置:jsp学习站首页 >> JAVA类 >> JAVA考试 >> SCJP认证套题解析之三

SCJP认证套题解析之三 (1)

[ 来源:互网络 | 更新日期:2007-09-17 04:14:20 | 浏览次数:10698]
简介:long l = 4990;B
41、Which of the following statements are legal?
A. long l = 4990;
B. int i = 4L;
C. float f = 1.1;
D. double d = 34.4;
E. double t = 0.9F.
(ade)
题目:下面的哪些声明是合法的。
此题的考点是数字的表示法和基本数据类型的类型自动转换,没有小数点的数字被认为是int型数,带有小数点的数被认为是double型的数,其它的使用在数字后面加一个字母表示数据类型,加l或者L是long型,加d或者D是double,加f或者F是float,可以将低精度的数字赋值给高精度的变量,反之则需要进行强制类型转换,例如将int,short,byte赋值给long型时不需要显式的类型转换,反之,将long型数赋值给byte,short,int型时需要强制转换(int a=(int)123L;)。

42、
public class Parent {
int change() {…}
}
class Child extends Parent {

}
Which methods can be added into class Child?
A. public int change(){}
B. int chang(int i){}
C. private int change(){}
D. abstract int chang(){}
(ab)
题目:哪些方法可被加入类Child。
这个题目的问题在第35题中有详尽的叙述。需要注意的是答案D的内容,子类可以重写父类的方法并将之声明为抽象方法,但是这引发的问题是类必须声明为抽象类,否则编译不能通过,而且抽象方法不能有方法体,也就是方法声明后面不能带上那两个大括号({}),这些D都不能满足。

43、
class Parent {
String one, two;
public Parent(String a, String b){
one = a;
two = b;
}
public void print(){ System.out.println(one); }
}
public class Child extends Parent {
public Child(String a, String b){
super(a,b);
}
public void print(){
System.out.println(one + " to " + two);
}
public static void main(String arg[]){
Parent p = new Parent("south", "north");
Parent t = new Child("east", "west");
p.print();
t.print();
}
}
Which of the following is correct?
A. Cause error during compilation.
B. south
east
C. south to north
east to west
D. south to north
east
E. south
east to west
(e)
题目:下面的哪些正确。
A. 在编译时出错。
这个题目涉及继承时的多态性问题,在前面的问题中已经有讲述,要注意的是语句t.print();在运行时t实际指向的是一个Child对象,即java在运行时决定变量的实际类型,而在编译时t是一个Parent对象,因此,如果子类Child中有父类中没有的方法,例如printAll(),那么不能使用t.printAll()。参见12题的叙述。

44、A Button is positioned in a Frame. Only height of the Button is affected by the Frame while the width is not. Which layout manager should be used?
A. FlowLayout
B. CardLayout
C. North and South of BorderLayout
D. East and West of BorderLayout
E. GridLayout
(d)
题目:一个按钮放在一个框架中,在框架改变时只影响按钮的高度而宽度不受影响,应该使用哪个布局管理器?
这个还是布局管理器的问题,流布局管理器(FlowLayout)将根据框架的大小随时调整它里面的组件的大小,包括高度和宽度,这个管理器不会约束组件的大小,而是允许他们获得自己的最佳大小,一行满了以后将在下一行放置组
[1] [2] [3] [4] [5]
Tags:关键字:SCJP认证套题解析之三
责任编辑:glen