41Which 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.
42public 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(){}
43class 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
44A 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
45Given the following code:
1) class Parent {
2) private String name;
3) public Parent(){}
4) }
5) public class Child extends Parent {
6) private String department;
7) public Child() {}
8) public String getValue(){ return name; }
9) public static void main(String arg[]) {
10) Parent p = new Parent();
11) }
12) }
Which line will cause error?
A. line 3
B. line 6
C. line 7
D. line 8
E. line 10
46The variable "result" is boolean. Which expressions are
legal?
A. result = true;
B. if ( result ) { // do something... }
C. if ( result!= 0 ) { // so something... }
D. result = 1
47Class Teacher and Student are subclass of class Person.
Person p;
Teacher t;
Student s;
p, t and s are all non-null.
if(t instanceof Person) { s = (Student)t; }
What is the result of this sentence?
A. It will construct a Student object.
B. The expression is legal.
C. It is illegal at compilation.
D. It is legal at compilation but possible illegal at runtime.
48Given 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).
49Given 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.
50Given 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().
(ade),(ab),(e),(d),(d),(ab),(c),(b),(ac),(d)
|