SCJP模拟试题:SCJPMockExam(1)
来源:优易学  2011-11-28 16:12:43   【优易学:中国教育考试门户网】   资料下载   IT书店


Q51
Which statements concerning the methods notify() and notifyAll() are true?

1) Instances of class Thread have a method called notify().
2) A call to the method notify() will wake the thread that currently owns the monitor of the object.
3) The method notify() is synchronized.
4) The method notifyAll() is defined in class Thread.
5) When there is more than one thread waiting to obtain the monitor of an object, there is no way to be sure which thread will be notified by the notify() method.

Q52
Which statements concerning the correlation between the inner and outer instances of non-static inner classes are true?

1) Member variables of the outer instance are always accessible to inner instances, regardless of their accessibility modifiers.
2) Member variables of the outer instance can never be referred to using only the variable name within the inner instance.
3) More than one inner instance can be associated with the same outer instance.
4) All variables from the outer instance that should be accessible in the inner instance must be declared final.
5) A class that is declared final cannot have any inner classes.

Q53
What will be the result of attempting to compile and run the following code?

public class Q6b0c {
public static void main(String args[]) {
int i = 4;
float f = 4.3;
double d = 1.8;
int c = 0;
if (i == f) c++;
if (((int) (f + d)) == ((int) f + (int) d)) c += 2;
System.out.println(c);
}
}

1) The code will fail to compile.
2) 0 will be written to the standard output.
3) 1 will be written to the standard output.
4) 2 will be written to the standard output.
5) 3 will be written to the standard output.

Q54
Which operators will always evaluate all the operands?

1) ||
2) +
3) &&
4) ? :
5) %

Q55
Which statements concerning the switch construct are true?

1) All switch statements must have a default label.
2) There must be exactly one label for each code segment in a switch statement.
3) The keyword continue can never occur within the body of a switch statement.
4) No case label may follow a default label within a single switch statement.
5) A character literal can be used as a value for a case label.

Q56
Which modifiers and return types would be valid in the declaration of a working main() method for a Java standalone application?

1) private
2) final
3) static
4) int
5) abstract

Q57
What will be the appearance of an applet with the following init() method?

public void init() {
add(new Button("hello"));
}

1) Nothing appears in the applet.
2) A button will cover the whole area of the applet.
3) A button will appear in the top left corner of the applet.
4) A button will appear, centered in the top region of the applet.
5) A button will appear in the center of the applet.

Q58
Which statements concerning the event model of the AWT are true?

1) At most one listener of each type can be registered with a component.
2) Mouse motion listeners can be registered on a List instance.
3) There exists a class named ContainerEvent in package java.awt.event.
4) There exists a class named MouseMotionEvent in package java.awt.event.
5) There exists a class named ActionAdapter in package java.awt.event.

Q59
Which statements are true, given the code new FileOutputStream("data", true) for creating an object of class FileOutputStream?

1) FileOutputStream has no constructors matching the given arguments.
2) An IOExeception will be thrown if a file named "data" already exists.
3) An IOExeception will be thrown if a file named "data" does not already exist.
4) If a file named "data" exists, its contents will be reset and overwritten.
5) If a file named "data" exists, output will be appended to its current contents.

Q60
Given the following code, write a line of code that, when inserted at the indicated location, will make the overriding method in Extension invoke the overridden method in class Base on the current object.

class Base {
public void print() {
System.out.println("base");
}
}
class Extention extends Base {
public void print() {
System.out.println("extension");
// insert line of implementation here
}
}
public class Q294d {
public static void main(String args[]) {
Extention ext = new Extention();
ext.print();
}
}

Fill in a single line of implementation.

上一页  [1] [2] [3] [4] [5] [6] [7] 下一页

责任编辑:小草

文章搜索:
 相关文章
热点资讯
热门课程培训