高分求解,谢谢拉!过几天就考拉!

flymouse200x 2003-10-18 10:32:08
35. You are assigned the task of building a panel containing a TextArea at the top, a label directly below it, and a button directly below the label. If the three components are added directly to the panel, which layout manager can the panel use to ensure that the TextArea absorbs all of the free vertical space when the panel is resized?

A. GridLayout
B. CardLayout
C. FlowLayout
D. BorderLayout
E. GridBagLayout
题目的意思能解释下吗?

40. What writes the text “<end>” to the end of the file “file.txt”?

A. OutputStream out= new FileOutputStream (“file.txt”);
Out.writeBytes (“<end>/n”);
B. OutputStream os= new FileOutputStream (“file.txt”, true);
DataOutputStream out = new DataOutputStream(os);
out.writeBytes (“<end>/n”);
C. OutputStream os= new FileOutputStream (“file.txt”);
DataOutputStream out = new DataOutputStream(os);
out.writeBytes (“<end>/n”);
D. OutputStream os= new OutputStream (“file.txt”, true);
DataOutputStream out = new DataOutputStream(os);
out.writeBytes (“<end>/n”);
请问下
OutputStream os=new FileOutputStream("file.txt",true);
DataOutputStream out=new DataOutputStream(os);
out.writeBytes("<end>/n");

OutputStream os=new FileOutputStream(new File(file.txt),true);
DataOutputStream out=new DataOutputStream(os);
out.writeBytes("<end>/n");
有什么区别吗?我在机子上试过 ,好象第二个会编译错误,
另外,这里的true 是不是指在数据流os后面可以加入数据流
要是没有这个true ,则“end”不能加入到里面去呢?


111. Given:

1. public class Foo {
2. private int val;
3. public foo(int v) (val = v;) }
4. public static void main (String [] args) {
5. Foo a = new Foo (10);
6. Foo b = new Foo (10);
7. Foo c = a;
8. int d = 10;
9. double e = 10.0;
10. }
11. }

101。Which three logical expressions evaluate to true? (Choose Three)

A.(a ==c)
B.(d ==e)
C.(b ==d)
D.(a ==b)
E.(b ==c)
F.(d ==10.0)
我认为选a,d,e,f
答案选a,b,f
请教


有道题目有分歧!
125 Which two statements are true regarding the creation of a default constructor? (Choose Two)

A. The default constructor initializes method variables.
B. The compiler always creates a default constructor for every class.
C. The default constructor invokes the no-parameter constructor of the superclass.
D. The default constructor initializes the instance variables declared in the class.
E. When a class has only constructors with parameters, the compiler does not create a default constructor.

我觉得D,E对的,E是肯定对的,而D中说默认构造器初始化事例变量也应该是对的啊?答案却认为
c,e是对的!请教高手

Which statement is true?

A. The Error class is a untimeException.
B. No exceptions are subclasses of Error.
C. Any statement that may throw an Error must be enclosed in a try block.
D. Any statement that may throw an Exception must be enclosed in a try block.
E. Any statement that may thro a runtimeException must be enclosed in a try block.
这里我认为没有答案:
a是明显错误的,b中,Error也应该算是一个异常啊,它有子类的啊/
c中Error是未检测异常,所以不需要在try块中
d中当抛出的是未检测异常时就不需要放在try中,e同理

143. Given:

1. public class MethodOver {
2. private int x, y;
3. private float z;
4. public void setVar(int a, int b, float c){
5. x = a;
6. y = b;
7. z = c;
8. }
9. }

Which two overload the setVar method? (Choose Two)

A. void setVar (int a, int b, float c){
x = a;
y = b;
z = c;
}
B. public void setVar(int a, float c, int b) {
setVar(a, b, c);
}
C. public void setVar(int a, float c, int b) {
this(a, b, c);
}
D. public void setVar(int a, float b){
x = a;
z = b;
}
E. public void setVar(int ax, int by, float cz) {
x = ax;
y = by;
z = cz;
}
答案是b,d
d肯定是对的,就是b跟c有什么区别吗?



...全文
67 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
nilr 2003-10-20
  • 打赏
  • 举报
回复
都打过了,来晚了祝你好运!
noratong 2003-10-19
  • 打赏
  • 举报
回复
对了,error是异常吗????
我记得好像不是吧,应该肯定的说不是异常!
你还没有搞清楚异常和错误的区别,error是错误,而不是异常。
An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch. 这是jdk文档对error的解释中的第一句话,它就说了不应该try catch。你仔细看一下jdk文档。
我不知道你所说的未检测异常是什么异常,但runtimeException只是Exception的一个子类,那么它也一定要被捕捉。
我觉得E选项也是正确的,但相比之下,D选项说的正确些,因为所有的会抛出Exception的方法都应该被捕捉。如果你作过一定的练习就会知道,在jdk文档中的方法只要后面说明会抛出异常时,你要是在代码里没有进行捕捉的话,是连编译都通过不了的。

好了,我就说这么多吧,祝你考试顺利通过!
noratong 2003-10-19
  • 打赏
  • 举报
回复
143
C选项很明显的错误你没看出来???
this(a, b, c);这个是什么方法???this是代表类本身,它又不是一个方法名。
没有这种写法吧,要是调用它自己本身的方法也要写成this.setVar(a, b, c);,或者是省掉this,用B选项的那种调用方式。
sunnyboy0819 2003-10-19
  • 打赏
  • 举报
回复
111题答案没错,d,e 基本类型能自动转换,'=='这个字符用于比较对象是否相等.
125题答案也没错.C说的是默认构造函数调用父类不带参数的构造函数,确实是这样的.D错在实例变量是不能在构造函数中声明的,应该在类块里.
143题的C this(a,b,c)指的是本类的带参数的构造方法,而类中没有给出定义.
朋友,你是考1.2吗?我也要考了,不过我打算考1.4,所以有关输入输出我就没看.
多多联系吧!~
noratong 2003-10-19
  • 打赏
  • 举报
回复
只要是异常必须被捕捉,也就是必须被放在trycatch块中。选择D。
noratong 2003-10-19
  • 打赏
  • 举报
回复
125 你记住一点,编译器只有在你没有为你的类创建构造函数时,才为你创建一个缺省的构造函数,而创建的缺省的构造函数是什么事都不作的,只是一个空实现。所以即使有变量,它也不会为你初始化它们。
noratong 2003-10-19
  • 打赏
  • 举报
回复
101 之所以d和e不选,是因为a,b,c三着都是对象,它们的类型并不是不同的数据类型,它们之间的比较不是比较的它们的属性val,而是比较的它的在内存中是否指向同一个地址空间,因为把a付给了c,所以a和c都指向同一个地址空间,而b却指向的是另一个地址空间,所以与它们都不相等。

而B选项之所以对,是因为不同数字类型的变量进行进行比较时系统会自动把它们转换成它们之中级别较高的那种数字类型,然后进行比较。
lrping 2003-10-19
  • 打赏
  • 举报
回复
You are assigned the task of building a panel containing a TextArea at the top, a label directly below it, and a button directly below the label. If the three components are added directly to the panel, which layout manager can the panel use to ensure that the TextArea absorbs all of the free vertical space when the panel is resized
译文大体如下:
请构造一个包含如下组件的面板,面板最上面是一个文本区(textarea),文本区下面是
一个标签(label),再下面就是一个按钮(button),如果这三个组件都是直接添加在这个面
板上的,那么,选择哪一种类型的layout manager ,能够保证当面板的大小被重新设置后文本区能得到全部的垂直空间。
noratong 2003-10-19
  • 打赏
  • 举报
回复
35 c
40 d
那两个没什么区别,之所以编译错误是因为你把file的构造函数都用错了,里面的参数应该是字符串。
jinzongnan 2003-10-19
  • 打赏
  • 举报
回复
40 我猜OutputStream os=new FileOutputStream(new File(file.txt),true);这句出错可能是因为你的目录下已经存在了一个file.txt所以它在创建一个新文件的时候出错the file is already exist. 试试把file.txt删掉。

if true, then bytes will be written to the end of the file rather than the beginning

111
好好研究 == 和 .equals方法的区别 1 什么时候比较值;2 什么时候比较引用。

我有事,有空再聊,把你做的模拟题都发给我好吗(全套的)?谢谢 jinzongnan@263.net

50,503

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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