📄 困难.txt
字号:
第1题:
String s= "hello ";
String t = "hello";
char c[] = {’h’,’e’,’l’,’l’,’o’} ;
Which return true?
A. s.equals(t);
B. t.equals(c);
C. s==t;
D. t.equals(new String("hello"));
E. t==c.
***
第2题:
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.
***
第3题:
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(){}
***
第4题:
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
***
第5题:
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
***
第6题:
Given 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
***
第7题:
The 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
***
第8题:
Class 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.
***
第9题:
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).
***
第10题:
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.
***
第11题:
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().
***
第12题:
Which is not a method of the class InputStream?
A. int read(byte[])
B. void flush()
C. void close()
D. int available()
***
第13题:
Which class is not subclass of FilterInputStream?
A. DataInputStream
B. BufferedInputStream
C. PushbackInputStream
D. FileInputStream
***
第14题:
Which classes can be used as the argument of the constructor of the class FileInputStream?
A. InputStream
B. File
C. FileOutputStream
D. String
***
第15题:
Which classes can be used as the argument of the constructor of the class FilterInputStream?
A. FilterOutputStream
B. File
C. InputStream
D. RandomAccessFile
***
第16题:
Given the following code fragment:
1) switch(m)
2) { case 0: System.out.println("case 0");
3) case 1: System.out.println("case 1"); break;
4) case 2:
5) default: System.out.println("default");
6) }
Which value of m would cause "default" to be the output?
A. 0
B. 1
C. 2
D. 3
***
第17题:
Given the uncompleted method:
1)
2) { success = connect();
3) if (success==-1) {
4) throw new TimedOutException();
5) }
6)}
TimedOutException is not a RuntimeException. Which can complete the method of declaration when added at line 1?
A. public void method()
B. public void method() throws Exception
C. public void method() throws TimedOutException
D. public void method() throw TimedOutException
E. public throw TimedOutException void method()
***
第18题:
Which of the following answer is correct to express the value 10 in hexadecimal number?
A. 0xA
B. 0x16
C. 0A
D. 016
***
第19题:
Which statements about thread are true?
A. Once a thread is created, it can star running immediately.
B. To use the start() method makes a thread runnable, but it does not necessarily start immediately.
C. When a thread stops running because of pre-emptive, it is placed at the front end of the runnable queue.
D. A thread may cease to be ready for a variety of reasons.
***
第20题:
The method resume() is responsible for resuming which thread's execution?
A. The thread which is stopped by calling method stop()
B. The thread which is stopped by calling method sleep()
C. The thread which is stopped by calling method wait()
D. The thread which is stopped by calling method suspend()
***
第21题:
Given the following code:
1) public class Test {
2) int m, n;
3) public Test() {}
4) public Test(int a) { m=a; }
5) public static void main(String arg[]) {
6) Test t1,t2;
7) int j,k;
8) j=0; k=0;
9) t1=new Test();
10) t2=new Test(j,k);
11) }
12) }
Which line would cause one error during compilation?
A. line 3
B. line 5
C. line 6
D. line 10
***
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -