★★★ 难题求解!请帮忙! ★★★ (能写几个就写几个吧)

tolixiaohui 2004-01-03 02:22:15
Question 19)
You are browsing the Java HTML documentation for information on the java.awt.TextField component. You want to create Listener

code to respond to focus events. The only Listener method listed is addActionListener. How do you go about finding out about

Listener methods.
1) Define your own Listener interface according to the event to be tracked
2) Use the search facility in the HTML documentation for the listener needed
3) Move up the hierarchy in the HTML documentation to locate methods in base
classes
4) Subclass awt.event with the appropriate Listener method



Question 21:)4
In the following code fragment from an applet, we know that the getParameter call may return a null if there is no parameter

named size. Which logical operator should replace X in line 5 to ensure that a NullPointerException is not generated if tmp

is null.
1. int sz;
2. public void init(){
3. sz=10;
4. String tmp=getParameter("size");
5. if(tmp!=null X tmp.equals("BIG")) sz=20;
6. }
a). Replace X with '&'
b). Replace X with '&&'
c). Replace X with '|'
d). Replace X with '||'


Question 23: [Check all correct answers] )bcd
You are writing a java class in a file named "MyClass.java", this class must be accessible by all classes in a large project.

Which of the following would be correct class declarations?
a. private class MyClass extends Object
b. class myclass extends Object
c. public class MyClass
d. public class MyClass extends Object


Question 24: [Check all correct answers]
Once created, some Java objects are "immutable", meaning they can not have their contents changed. Which of the following

classed produce immutable objects?
a. java.lang.Double
b. java.lang.StringBuffer
c. java.lang.Boolean
d. java.lang.Math


41.容器被重新设置大小后,哪种布局管理器的容器中的组件大小不随容器大小的变化而改变?
A CardLayout
B FlowLayout
C BorderLayout
D GridLayout

Question 46: 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 {
}


Question47: What statements are true concerning the method notify() that is used in conjunction with wait()? d
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



Question 52: 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();
...全文
53 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
tolixiaohui 2004-01-06
  • 打赏
  • 举报
回复
又不都是!
也不是SJCP
xujinglei 2004-01-05
  • 打赏
  • 举报
回复
GUI和I/O都不考了,你在这里贴这么几道题目干吗呢!
tolixiaohui 2004-01-04
  • 打赏
  • 举报
回复
Question 19)
You are browsing the Java HTML documentation for information on the java.awt.TextField component. You want to create Listener code to respond to focus events. The only Listener method listed is addActionListener. How do you go about finding out about Listener methods.
1) Define your own Listener interface according to the event to be tracked
2) Use the search facility in the HTML documentation for the listener needed
3) Move up the hierarchy in the HTML documentation to locate methods in base
classes
4) Subclass awt.event with the appropriate Listener method



Question 21:)4
In the following code fragment from an applet, we know that the getParameter call may return a null if there is no parameter named size. Which logical operator should replace X in line 5 to ensure that a NullPointerException is not generated if tmp is null.
1. int sz;
2. public void init(){
3. sz=10;
4. String tmp=getParameter("size");
5. if(tmp!=null X tmp.equals("BIG")) sz=20;
6. }
a). Replace X with '&'
b). Replace X with '&&'
c). Replace X with '|'
d). Replace X with '||'




Question 24: [Check all correct answers]
Once created, some Java objects are "immutable", meaning they can not have their contents changed. Which of the following classed produce immutable objects?
a. java.lang.Double
b. java.lang.StringBuffer
c. java.lang.Boolean
d. java.lang.Math



Question 46: 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 {
}


Question47: What statements are true concerning the method notify() that is used in conjunction with wait()? d
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



Question 52: 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();



Question 19 bc
Which of the following are organizing principles of Java's "javadoc" format documentation for a given class?
a) Relative frequency of use of the various methods.
b) Lists of methods in a class in alphabetic order.
c) Separate listing of private, protected and public methods in a class.


Q. 33 a
With which I/O operation can we append, update a file?
a) RandomAccessFile()
b) Outputstream()
c) DataOutputstream()
tolixiaohui 2004-01-04
  • 打赏
  • 举报
回复
tolixiaohui 2004-01-03
  • 打赏
  • 举报
回复

很简单的吧!
danceflash 2004-01-03
  • 打赏
  • 举报
回复
21.b). Replace X with '&&'
短路运算符

62,628

社区成员

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

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