SCJP模拟试题[1](3)
添加时间: 2007-9-23 1:58:11 作者: JAVA题库 阅读次数:96 来源: http://www.d9soft.com
class Test {
public static void main(String[] args) {
Thread t = new Thread(new RunHandler());
t.start();
}
}
Select all valid answers.
a) RunHandler must implement the java.lang.Runnable interface.
b) RunHandler must extend the Thread class.
c) RunHandler must provide a run() method declared as public and returning void.
d) RunHandler must provide an init() method.
----------------------------------
Question 27: To determine if you can invoke addContainerListener() for a component referenced using a variable named c, which expression(s) can you evaluate that will give you a true or false answer to this questions?
Select all valid answers.
a) c == Container
b) c.equals(Class.Container)
c) c instanceof Container
d) c instanceof Component
e) c implements Container
------------------------------------------
Question 28: Write a statement for a constructor that invokes the no-args, default constructor in its superclass.
Fill in the blank.
-------------------------------------------
Question 29: What is written to the standard output given the following statement:
System.out.println(4 & 7);
Select the one right answer.
a) 4
b) 5
c) 6
d) 7
e) 0
--------------------------------------------
Question 30: What will the following block of code write to the standard output when it is executed?
int i = 3;
int j = 0;
double k = 3.2;
if (i < k)
if (i == j)
System.out.println(i);
else
System.out.println(j);
else
System.out.println(k);
Select the one right answer.
a) 3
b) 0
c) 3.2
d) none of these
-----------------------------------------------
Question 31: How can you use the String method indexOf() to determine which position the letter 'C' is in given this String:
String s = "ABCDE";
Write a complete statement in your answer, but you do not have to assign the letter you retrieve to another variable.
Fill in the blank.
----------------------------------------------
Question 32: Given that the variable g references a valid Graphics object, what does the following statement do?
g.fillRect(2, 3, 10, 20);
Select all valid answers.
a) draw the outline of a rectangle in the current background color
b) draw the outline of a rectangle in the current foreground color
c) fill in a rectangle using the current background color
d) fill in a rectangle using the current foreground color
e) fill in a rectangle in black
-----------------------------------------------
Question 33: Describe the following applet.
import java.applet.Applet;
import java.awt.event.*;
import java.awt.*;
public class MyApplet extends Applet {
Button b1, b2;
public void init() {
ActionListener a = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
if (evt.getSource() == b1) {
b1.setEnabled(false);
b2.setEnabled(true);
} else {
b1.setEnabled(true);
b2.setEnabled(false);
}
}
};
b1 = new Button("1");
b1.addActionListener(a);
add(b1);
b2 = new Button("2");
b2.addActionListener(a);
add(b2);
}
}
Select all valid answers.
a) Nothing appears in the applet
b) One button appears in the applet but does nothing
c) Two buttons appear in the applet
d) When the user clicks a button, nothing happens
e) When the user clicks a button, it becomes disabled
f) When a user clicks a button, the other button becomes enabled
Fill in the blank.
----------------------------------------
Question 41: What is the final value of temp in this sequence?
long temp = (int)3.9;
temp %= 2;
a) 0
b) 1
c) 2
d) 3
e) 4
Select the one right answer.
-----------------------------------------
Question 42: Analyze this line of code:
if (5 & 7 > 0 && 5 2) System.out.println("true");
Select the one right answer.
a) this line of code will not compile
b) this code will compile but nothing will appear in the standard output
c) this code will compile and write the word "true" in the standard output
----------------------------------------------
Question 43: Create a List object that allows multiple selections and displays 5 rows at a time.
Start by writing:
List l =
in your answer.
Fill in the blank.
----------------------------------------------
Question 44: What will the user interface look like in an applet given the following init() method?
public void init() {
setLayout(new BorderLayout());
add("East", new Button("hello"));
}
Select the one right answer.
a) Nothing will appear in the applet
b) A button will appear in the applet set in the exact center
c) A button will appear on the left side of the applet
d) A button will appear on the right side of the applet
e) A button will fill the entire applet
----------------------------------------
Question 45: Choose all true statements about the paint() method defined in the Component class:
Select all valid answers.
a) it is protected
b) it takes an instance of class Graphics
c) it is static
d) it is invoked automatically whenever you minimize and then maximize a component, such as a window
e) there is also a version that takes an int
上一篇文章: SCJP模拟试题[1](2) 下一篇文章: Java认证模拟题及分析(1)

](/d9soft/images/logo_1.gif)