第1题:
Which of the following range of short is correct?
a:-27 -- 27-1 b:0 -- 216-1 c:215 -- 215-1 d:–231 -- 231-1
***
第2题:
Which declarations of identifiers are legal?
A. $persons B. TwoUsers C. *point D. this E. _endline
***
第3题:
Which statement of assigning a long type variable to a hexadecimal value is correct?
A. long number = 345L; B. long number = 0345; C. long number = 0345L; D. long number = 0x345L.
***
第4题:
Which of the following fragments might cause errors?
A. String s = "Gone with the wind";
String t = " good ";
String k = s + t;
B. String s = "Gone with the wind";
String t;
t = s[3] + "one";
C. String s = "Gone with the wind";
String standard = s.toUpperCase();
D. String s = "home directory";
String t = s - "directory".
***
第5题:
class Person {
private int a;
public int change(int m){ return m; }
}
public class Teacher extends Person {
public int b;
public static void main(String arg[]){
Person p = new Person();
Teacher t = new Teacher();
int i;
// point x
}
}
Which are syntactically valid statement at// point x?
A. i = m;
B. i = b;
C. i = p.a;
D. i = p.change(30);
E. i = t.b.
***
第6题:
Which layout manager is used when the frame is resized the buttons’s position in the Frame might be changed?
A. BorderLayout
B. FlowLayout
C. CardLayout
D. GridLayout
***
第7题:
Given the following code fragment:
1) public void create() {
2) Vector myVect;
3) myVect = new Vector();
4) }
Which of the following statements are true?
A. The declaration on line 2 does not allocate memory space for the variable myVect.
B. The declaration on line 2 allocates memory space for a reference to a Vector object.
C. The statement on line 2 creates an object of class Vector.
D. The statement on line 3 creates an object of class Vector.
E. The statement on line 3 allocates memory space for an object of class Vector
***
第8题:
Which of the following answer is correct to express the value 8 in octal number?
A. 010
B. 0x10
C. 08
D. 0x8
***
第9题:
Which are not Java keywords?
A. TRUE
B. sizeof
C. const
D. super
E. void
***
第10题:
Which of the following statements are true?
A. The equals() method determines if reference values refer to the same object.
B. The == operator determines if the contents and type of two separate objects match.
C. The equals() method returns true only when the contents of two objects match.
D. The class File overrides equals() to return true if the contents and type of two separate objects match.
***
第11题:
11、Which statements about inheritance are true?
A. In Java programming language only allows single inheritance.
B. In Java programming language allows a class to implement only one interface.
C. In Java programming language a class cannot extend a class and implement a interface together.
D. In Java programming language single inheritance makes code more reliable.
***
第12题:
1) class Person {
2) public void printValue(int i, int j) {/*…*/ }
3) public void printValue(int i){/*...*/ }
4) }
5) public class Teacher extends Person {
6) public void printValue() {/*...*/ }
7) public void printValue(int i) {/*...*/}
8) public static void main(String args[]){
9) Person t = new Teacher();
10) t.printValue(10);
11) }
12) }
Which method will the statement on line 10 call?
A. on line 2
B. on line 3
C. on line 6
D. on line 7
***
第13题:
Which are not Java primitive types?
A. short
B. Boolean
C. unit
D. float
***
第14题:
Use the operators "<<", ">>", which statements are true?
A. 0000 0100 0000 0000 0000 0000 0000 0000<<5 gives
1000 0000 0000 0000 0000 0000 0000 0000
B. 0000 0100 0000 0000 0000 0000 0000 0000<<5 gives
1111 1100 0000 0000 0000 0000 0000 0000
C. 1100 0000 0000 0000 0000 0000 0000 0000>>5 gives
1111 1110 0000 0000 0000 0000 0000 0000
D. 1100 0000 0000 0000 0000 0000 0000 0000>>5 gives
0000 0110 0000 0000 0000 0000 0000 0000
***
第15题:
Which of the following range of int is correct?
A. -27 -- 27-1
B. 0 – 232-1
C. –215 -- 215-1
D. –231 -- 231-1
***
第16题:
Which keyword should be used to enable interaction with the lock of an object? The flag allows exclusive access to that object.
A. transient
B. synchronized
C. serialize
D. static
***
第17题:
Which is the return type of the method main()?
A. int
B. void
C. boolean
D. static
***
第18题:
Given the following code:
if (x>0) { System.out.println("first"); }
else if (x>-3) { System.out.println("second"); }
else { System.out.println("third"); }
Which range of x value would print the string "second"?
A. x > 0
B. x > -3
C. x <= -3
D. x <= 0 & x > -3
***
第19题:
Given the following expression about TextField which use a proportional pitch font.
TextField t = new TextField("they are good",40);
Which statement is true?
A. The displayed string can use multiple fonts.
B. The maximum number of characters in a line will be 40.
C. The displayed width is exactly 40 characters.
D. The user can edit the characters.
***
第20题:
Which statements about the garbage collection are true?
A. The program developer must create a thread to be responsible for free the memory.
B. The garbage collection will check for and free memory no longer needed.
C. The garbage collection allow the program developer to explicity and immediately free the memory.
D. The garbage collection can free the memory used java object at expect time.
***
第21题:
21、Which of the following assignment is not correct?
A. float f = 11.1;
B. double d = 5.3E12;
C. double d = 3.14159;
D. double d = 3.14D.
***
第22题:
Given the uncompleted code of a class:
class Person {
String name, department;
int age;
public Person(String n){ name = n; }
public Person(String n, int a){ name = n; age = a; }
public Person(String n, String d, int a) {
// doing the same as two arguments version of constructor
// including assignment name=n,age=a
department = d;
}
}
Which expression can be added at the "doing the same as..." part of the constructor?
A. Person(n,a);
B. this(Person(n,a));
C. this(n,a);
D. this(name,age).
***
第23题:
Which of the following statements about variables and their scopes are true?
A. Instance variables are member variables of a class.
B. Instance variables are declared with the static keyword.
C. Local variables defined inside a method are created when the method is executed.
D. Local variables must be initialized before they are used.
***
第24题:
public void test() {
try { oneMethod();
System.out.println("condition 1");
} catch (ArrayIndexOutOfBoundsException e) {
System.out.println("condition 2");
} catch(Exception e) {
System.out.println("condition 3");
} finally {
System.out.println("finally");
}
}
Which will display if oneMethod run normally?
A. condition 1
B. condition 2
C. condition 3
D. finally
***
- 1
- 2
- 3
前往页