“图行天下”的java面试题,请高手帮忙,求解。

zhongzuo1981 2005-03-16 11:23:29
SCJP模拟试题一
--------------------------------------------------------------------------------
此套试题由60道题组成(实际考试为60道题)。

试题由单选题和多选题组成,单选题将提示:Select the one right answer.,多选题将提示:Select all valid answers.。

实际考试70%为通过,因此您必须在此套模拟试题中答对42题。
--------------------------------------------------------------------------------
Question 1: Given the following class definition:
class A {
protected int i;
A(int i) {
this.i = i;
}
}
Which of the following would be a valid inner class for this class?

Select all valid answers.
a)
class B {
}
b)

class B extends A {
}
c)

class B {
B() {
System.out.println("i = " + i);
}
}
d)
class B {
class A {
}
}
e)
class A {
}
answer
--------------------------------------------------------------------------------
Question 2: What statements are true concerning the method notify() that is used in conjunction with wait()?
Select all valid answers.
a) if there is more than one thread waiting on a condition, only the thread that has been waiting the longest is notified
b) if there is more than one thread waiting on a condition,there is no way to predict which thread will be notifed
c) notify() is defined in the Thread class
d) it is not strictly necessary to own the lock for the object you invoke notify() for
e) notify() should only be invoked from within a while loop
answer
--------------------------------------------------------------------------------
Question 3: Given the following class:
class Counter {
public int startHere = 1;
public int endHere = 100;
public static void main(String[] args) {
new Counter().go();
}
void go() {
// A
Thread t = new Thread(a);
t.start();
}
}
What block of code can you replace at line A above so that this program will count from startHere to endHere?
Select all valid answers.
a)
Runnable a = new Runnable() {
public void run() {
for (int i = startHere; i <= endHere; i++) {
System.out.println(i);
}
}
};
b)
a implements Runnable {
public void run() {
for (int i = startHere; i <= endHere; i++) {
System.out.println(i);
}
}
};
c)
Thread a = new Thread() {
public void run() {
for (int i = startHere; i <= endHere; i++) {
System.out.println(i);
}
}
};
answer
--------------------------------------------------------------------------------
Question 4: 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
answer
--------------------------------------------------------------------------------
Question 5: Given the following class:
class Counter {
public static void main(String[] args) {
Thread t = new Thread(new CounterBehavior());
t.start();
}
}
Which of the following is a valid definition of CounterBehavior that would make Counter’s main() method count from 1 to 100, counting once per second?
Select the one right answer.
a)This class is an inner class to Counter:
class CounterBehavior {
for (int i = 1; i <= 100; i++);
try {
System.out.println(i);
Thread.sleep(1000);
} catch (InterruptedException x) {}
}
}
b) This class is an inner class to Counter:
class CounterBehavior implements Runnable {
public void run() {
for (int i = 1; i <= 100; i++);
try {
System.out.println(i);
Thread.sleep(1000);
} catch (InterruptedException x) {}
}
}
}
c) This class is a top-level class:
static class CounterBehavior implements Runnable {
public void run() {
try {
for (int i = 1; i <= 100; i++) {
System.out.println(i);
Thread.sleep(1000);
}
} catch (InterruptedException x) {}
}
}
answer
--------------------------------------------------------------------------------
Question 6: Given the following class definition:
class A {
public int x;
private int y;
class B {
protected void method1() {
}
class C {
private void method2() {
}
}
}
}

class D extends A {
public float z;
}
 
What can method2() access directly, without a reference to another instance?
Select all valid answers.
a) the variable x defined in A
b) the variable y defined in A
c) method1 defined in B
d) the variable z defined in D
answer
--------------------------------------------------------------------------------
Question 7: You have an 8-bit file using the character set defined by ISO 8859-8. You are writing an application to display this file in a TextArea. The local encoding is already set to 8859-8. How can you write a chunk of code to read the first line from this file?
You have three variables accessible to you:
myfile is the name of the file you want to read
stream is an InputStream object associated with this file
s is a String object
Select all valid answers.
a)
InputStreamReader reader = new InputStreamReader(stream, "8859-8");
BufferedReader buffer = new BufferedReader(reader);
s = buffer.readLine();
b)
InputStreamReader reader = new InputStreamReader(stream);
BufferedReader buffer = new BufferedReader(reader);
s = buffer.readLine();
c)
InputStreamReader reader = new InputStreamReader(myfile, "8859-8");
BufferedReader buffer = new BufferedReader(reader);
s = buffer.readLine();
d)
InputStreamReader reader = new InputStreamReader(myfile);
BufferedReader buffer = new BufferedReader(reader);
s = buffer.readLine();
e)
FileReader reader = new FileReader(myfile);
BufferedReader buffer = new BufferedReader(reader);
s = buffer.readLine();
answer
--------------------------------------------------------------------------------
Question 8: How can you write a line of code for an applet’s init() method that determines how wide the applet is?
Select all valid answers.
a) int width = this.getY();
b) int width = this.getSize().w;
c) int width = getSize();
d) int width = getSize().w;
e) int width = getWidth();
answer
--------------------------------------------------------------------------------
Question 9: For a variable width font, how "wide" is a TextField created using the expression:
new TextField(20)
Select the one right answer.
a) 20 times the average of all the characters in the font used for this TextField object
b) 20 times the width of the letter M
c) 20 times the width of the letter a
d) 20 inches
e) 20 picas
answer
--------------------------------------------------------------------------------
Question 10: Given this interface definition:
interface A {
int method1(int i);
int method2(int j);
}
which of the following classes implement this interface and is not abstract?
Select all valid answers.
a)
class B implements A {
int method1() { }
int method2() { }
}

b)
class B {
int method1(int i) { }
int method2(int j) { }
}

c)
class B implements A {
int method1(int i) { }
int method2(int j) { }
}

d)
class B extends A {
int method1(int i) { }
int method2(int j) { }
}

e)
class B implements A {
int method2(int j) { }
int method1(int i) { }
}
answer
--------------------------------------------------------------------------------
...全文
632 29 打赏 收藏 转发到动态 举报
写回复
用AI写文章
29 条回复
切换为时间正序
请发表友善的回复…
发表回复
wlsugerFly 2010-06-02
  • 打赏
  • 举报
回复
shouyong
qjzrd 2005-03-24
  • 打赏
  • 举报
回复
接分来了
Nathalie 2005-03-24
  • 打赏
  • 举报
回复
60.a
59.a b e
58.d
57.a
56.e
zhongzuo1981 2005-03-24
  • 打赏
  • 举报
回复
看来我这100分要白扔了,
下面回帖的,我散分,唉……
yinghu 2005-03-23
  • 打赏
  • 举报
回复
图行天下不是中国的么?干吗出鸟文的试题?看不懂!
jxj12345678 2005-03-23
  • 打赏
  • 举报
回复
不会做。晕了。
liqian008 2005-03-23
  • 打赏
  • 举报
回复
up
zhongzuo1981 2005-03-23
  • 打赏
  • 举报
回复
继续啊
chinajava 2005-03-22
  • 打赏
  • 举报
回复
1.a,e
2 b
3 a,c
4 d
5 b
jwbecalm 2005-03-20
  • 打赏
  • 举报
回复
xq_zz 2005-03-20
  • 打赏
  • 举报
回复
scjp吗?这么多题目
zhongzuo1981 2005-03-20
  • 打赏
  • 举报
回复
??????????????????????????
zhongzuo1981 2005-03-19
  • 打赏
  • 举报
回复
高手在哪里啊????
给个参考吧
TraBant 2005-03-18
  • 打赏
  • 举报
回复
to chinajava(chinajava) :第一题是多选题-_-,答:abc。看在同是81年的,晚上有空话拿来做做,^_^。
gree001 2005-03-18
  • 打赏
  • 举报
回复
顶个。
zhongzuo1981 2005-03-16
  • 打赏
  • 举报
回复
楼上,怎么讲?
zhang21cnboy 2005-03-16
  • 打赏
  • 举报
回复
考,这种烂货!
zhongzuo1981 2005-03-16
  • 打赏
  • 举报
回复
Question 56: What will the user interface look like in an applet given the following init() method?
public void init() {
setLayout(new BorderLayout());
add(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 in the applet along the top and centered horizontally
d) A button will appear in the top left corner
e) A button will fill the entire applet
answer
--------------------------------------------------------------------------------
Question 57: What expressions are true concerning the following lines of code?
int[] arr = {1, 2, 3};
for (int i=0; i < 2; i++)
arr[i] = 0;
Select all valid answers.

a) arr[0] == 0
b) arr[0] == 1
c) arr[1] == 1
d) arr[2] == 0
e) arr[3] == 0
answer
--------------------------------------------------------------------------------
Question 58: What will happen if you try to compile and execute B’s main() method?
class A {
int i;
A(int i) {
this.i = i * 2;
}
}

class B extends A {
public static void main(String[] args) {
B b = new B(2);
}
B(int i) {
System.out.println(i);
}
}
Select the one right answer.

a) The instance variable i is set to 4
b) The instance variable i is set to 2
c) The instance variable i is set to 0
d) This code will not compile
answer
--------------------------------------------------------------------------------
Question 59: Which best describes the user interface of an applet given the following init() method:
public void init() {
setLayout(new BorderLayout());
add("North", new TextField(10));
add("Center", new Button("help"));
}
Select all valid answers.

a) The TextField object will be placed at the top of the applet and will be 10 columns wide
b) The Button object will be centered in the applet and will be just large enough to contain the text "help"
c) The Button object will be centered in the applet and will start at the left edge of the applet, fit just under the TextField object above it, and extend to the right and bottom edge of the applet
d) The TextField object will be placed along the top of the applet and will stretch from the left edge to the right edge
e) The placement of the Button object and the TextField object depends on the overall size of the applet.
answer
--------------------------------------------------------------------------------
Question 60: Which of the following statements about try, catch, and finally are true?
Select all valid answers.
a) A try block must always be followed by a catch block
b) A try block can be followed either by a catch block or a finally block, or both
c) A catch block must always be associated with a try block
d) A finally can never stand on its own (that is, without being associated with try block)
e) None of these are true
answer
taoxuwen 2005-03-16
  • 打赏
  • 举报
回复
想帮你答 无奈英语太烂,眼睛又不好使,只有帮顶了 抱歉!
Tsiah 2005-03-16
  • 打赏
  • 举报
回复
好冬冬哦
加载更多回复(9)

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧