computer 版 (精华区)
发信人: gutentag ( Bonjour && deeply in LOVE on the web ), 信区: program
标 题: JAVA 认证·测试模拟题(1)
发信站: 听涛站 (2001年06月22日15:41:09 星期五), 站内信件
【Bonjour && deeply in LOVE on the web】
Question 1
Which colour is used to indicate instance methods in the standard "javadoc"
format documentation:
blue
red
purple
orange
Select the most appropriate answer.
Question 2
What is the correct ordering for the import, class and package declarations
when
found in a single file?
package, import, class
class, import, package
import, package, class
package, class, import
Select the most appropriate answer.
Question 3
Which methods can be legally applied to a string object?
equals(String)
equals(Object)
trim()
round()
toString()
Select all correct answers.
Question 4
What is the parameter specification for the public static void main method?
String args []
String [] args
Strings args []
String args
Select all correct answers.
Question 5
What does the zeroth element of the string array passed to the public static
void
main method contain?
The name of the program
The number of arguments
The first argument if one is present
Select the most appropriate answer.
Question 6
Which of the following are Java keywords (as opposed to reserved words)?
goto
malloc
extends
FALSE
Select all correct answers
Question 7
What will be the result of compiling the following code:
public class Test {
public static void main (String args []) {
int age;
age = age + 1;
System.out.println("The age is " + age);
}
}
Compiles and runs with no output
Compiles and runs printing out The age is 1
Compiles but generates a runtime error
Does not compile
Compiles but generates a compile time error
Select the most appropriate answer.
Question 8
Which of these is the correct format to use to create the literal char value
a?
慳?/LI>
"a"
new Character(a)
\000a
Select the most appropriate answer.
Question 9
What is the legal range of a byte integral type?
0 - 65, 535
(?28) ?127
(?2,768) ?32,767
(?56) ?255
Select the most appropriate answer.
Question 10
Which of the following is illegal:
int i = 32;
float f = 45.0;
double d = 45.0;
Select the most appropriate answer.
Question 11
What will be the result of compiling the following code:
public class Test {
static int age;
public static void main (String args []) {
age = age + 1;
System.out.println("The age is " + age);
}
}
Compiles and runs with no output
Compiles and runs printing out The age is 1
Compiles but generates a runtime error
Does not compile
Compiles but generates a compile time error
Select the most appropriate answer.
Question 12
Which of the following are correct?
128 >> 1 gives 64
128 >>> 1 gives 64
128 >> 1 gives ?4
128 >>> 1 gives ?4
Select all correct answers
Question 13
Which of the following return true?
"john" == "john"
"john".equals("john")
"john" = "john"
"john".equals(new Button("john"))
Select all correct answers.
Question 14
Which of the following do not lead to a runtime error?
"john" + " was " + " here"
"john" + 3
3 + 5
5 + 5.5
Select all correct answers.
Question 15
Which of the following are so called "short circuit" logical operators?
&
||
&&
|
Select all correct answers.
Question 16
Which of the following are acceptable?
Object o = new Button("A");
Boolean flag = true;
Panel p = new Frame();
Frame f = new Panel();
Panel p = new Applet();
Select all correct answers.
Question 17
What is the result of compiling and running the following code:
public class Test {
static int total = 10;
public static void main (String args []) {
new Test();
}
public Test () {
System.out.println("In test");
System.out.println(this);
int temp = this.total;
if (temp > 5) {
System.out.println(temp);
}
}
}
The class will not compile
The compiler reports and error at line 2
The compiler reports an error at line 9
The value 10 is one of the elements printed to the standard output
The class compiles but generates a runtime error
Select all correct answers.
Question 18
Which of the following is correct:
String temp [] = new String {"j" "a" "z"};
String temp [] = { "j " " b" "c"}
String temp = {"a", "b", "c"}
String temp [] = {"a", "b", "c"}
Select the most appropriate answer.
Question 19
What is the correct declaration of an abstract method that is intended to be
public:
public abstract void add();
public abstract void add() {}
public abstract add();
public virtual add();
Select the most appropriate answer.
Question 20
Under what situations do you obtain a default constructor?
When you define any class
When the class has no other constructors
When you define at least one constructor
Select the most appropriate answer.
Question 21
Given the following code:
public class Test {
?
}
Which of the following can be used to define a constructor for this class:
public void Test() {
public Test() {
public static Test() {
public static void Test() {
Select the most appropriate answer.
Question 22
Which of the following are acceptable to the Java compiler:
if (2 == 3) System.out.println("Hi");
if (2 = 3) System.out.println("Hi");
if (true) System.out.println("Hi");
if (2 != 3) System.out.println("Hi");
if (aString.equals("hello")) System.out.println("Hi");
Select all correct answers.
Question 23
Assuming a method contains code which may raise an Exception (but not a
RuntimeException) what is the correct way for a method to indicate that it d
oes
not handle that exception:
throw Exception
throws Exception
new Exception
Don't need to specify anything
Select the most appropriate answer.
Question 24
What is the result of executing the following code, using the parameters 4 a
nd 0:
public void divide(int a, int b) {
try {
int c = a / b;
} catch (Exception e) {
System.out.print("Exception ");
} finally {
System.out.println("Finally");
}
Prints out: Exception Finally
Prints out: Finally
Prints out: Exception
No output
Select the most appropriate answer.
Question 25
Which of the following is a legal return type of a method overloading the
following method:
public void add(int a) {
void
int
Can be anything
Select the most appropriate answer.
Question 26
Which of the following statements is correct for a method which is overridin
g the
following method:
public void add(int a) {
the overriding method must return void
the overriding method must return int
the overriding method can return whatever it likes
Select the most appropriate answer.
Question 27
Given the following classes defined in separate files:
class Vehicle {
public void drive() {
System.out.println("Vehicle: drive");
}
}
class Car extends Vehicle {
public void drive() {
System.out.println("Car: drive");
}
}
public class Test {
public static void main (String args []) {
Vehicle v;
Car c;
v = new Vehicle();
c = new Car();
v.drive();
c.drive();
v = c;
v.drive();
}
}
What will be the effect of compiling and running this class Test?
Generates a Compiler error on the statement v= c;
Generates runtime error on the statement v= c;
Prints out:
Vehicle: drive
Car: drive
Car: drive
Prints out:
Vehicle: drive
Car: drive
Vehicle: drive
Select the most appropriate answer.
Question 28
Where in a constructor, can you place a call to a constructor defined in the
super class?
Anywhere
The first statement in the constructor
The last statement in the constructor
You can't call super in a constructor
Select the most appropriate answer.
--
春が来た、春が来た、どこに来た。
山に来た、郷に来た、野にも来た。
※ 来源:·听涛站 tingtao.dhs.org·[FROM: 匿名天使的家]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:1.234毫秒