SCJP模拟题,请教

qxksos 2002-10-23 05:44:30
2. Given:

Integer i = new Integer (42);
Long 1 = new Long (42);
Double d = new Double (42.0);

Which two expressions evaluate to True? (Choose Two)

A. (i ==1)
B. (i == d)
C. (d == 1)
D. (i.equals (d))
E. (d.equals (i))
F. (i.equals (42))

我试了一下好象没有对的呀
...全文
31 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
北极猩猩 2002-11-02
  • 打赏
  • 举报
回复
没有正确答案
equals在比较示范时类型不一致的一律返回false
北极猩猩 2002-11-02
  • 打赏
  • 举报
回复
没有正确答案
equals在比较示范时类型不一致的一律返回false
mercury1231 2002-10-29
  • 打赏
  • 举报
回复
A
qxjavajava 2002-10-28
  • 打赏
  • 举报
回复
/**
A. An instance of the Inner class can be constructed with “new Outer.Inner ()”
B. An instance of the inner class cannot be constructed outside of package foo
C. An instance of the inner class can only be constructed from within the outer class
D. From within the package bar, an instance of the inner class can be constructed with “new inner()”
*/
package foo;
public class Outer
{
public static class Inner
{
public void writeSt()
{
System.out.println("Hello");
}
}
}

class TryInner
{
public TryInner()
{
new Outer.Inner(); //-------------A is OK!!!! and C is wrong.
}
}
***************
/**
A. An instance of the Inner class can be constructed with “new Outer.Inner ()”
B. An instance of the inner class cannot be constructed outside of package foo
C. An instance of the inner class can only be constructed from within the outer class
D. From within the package bar, an instance of the inner class can be constructed with “new inner()”
*/
package bar;
class TryPack
{
public static void main(String[] args)
{
System.out.println("Hello World!");
//new Inner(); -----------This line is wrong so D is wrong;
new foo.Outer.Inner(); // You should write like this. and B is wrong
}
}
************************The Answer is A
gaojunbo 2002-10-28
  • 打赏
  • 举报
回复
这是一个static inner class.所以A是正确的。
qxksos 2002-10-28
  • 打赏
  • 举报
回复
13. Given:

1. package foo;
2.
3. public class Outer (
4. public static class Inner (
5. )
6. )

Which statement is true?

A. An instance of the Inner class can be constructed with “new Outer.Inner ()”
B. An instance of the inner class cannot be constructed outside of package foo
C. An instance of the inner class can only be constructed from within the outer class
D. From within the package bar, an instance of the inner class can be constructed with “new inner()”
mengz 2002-10-27
  • 打赏
  • 举报
回复
是147-2题吧? 好像应该是出错题了.
pcfoot 2002-10-26
  • 打赏
  • 举报
回复
de,不对,那就没有答案了
12 D
mercury1231 2002-10-26
  • 打赏
  • 举报
回复
a b c 都不符合语法规范,因为i d l 都是对象,不能用 == 来判断
f 也不符合语法规范,因为equals方法比较的是两个对象的值 int 数42 显然不是对象。
就盛d 和 e 了,可是浮点数42,与整形数42.0值是不同的呀。那就没有答案吧,scjp考试题里规定可以有没有答案的题。



我同意这位大虾的看法,equal()的用法要求对比的两个Object必须类型一致,值相同,才会返回true。

注:Compares this object against the specified object. The result is true if and only if the argument is not null and is a Double object that represents a double that has the same value as the double represented by this object.
zhuwenzheng 2002-10-24
  • 打赏
  • 举报
回复
answer is wrong
qxjavajava 2002-10-24
  • 打赏
  • 举报
回复
a b c 都不符合语法规范,因为i d l 都是对象,不能用 == 来判断
f 也不符合语法规范,因为equals方法比较的是两个对象的值 int 数42 显然不是对象。
就盛d 和 e 了,可是浮点数42,与整形数42.0值是不同的呀。那就没有答案吧,scjp考试题里规定可以有没有答案的题。
qxksos 2002-10-24
  • 打赏
  • 举报
回复
12. Which statement is true?

A. An anonymous inner class may be declared as final
B. An anonymous inner class can be declared as private
C. An anonymous inner class can implement multiple interfaces
D. An anonymous inner class can access final variables in any enclosing scope
E. Construction of an instance of a static inner class requires an instance of the enclosing outer class.

superboy007 2002-10-23
  • 打赏
  • 举报
回复
should be d,e
qxksos 2002-10-23
  • 打赏
  • 举报
回复
to:cxl528(诚诚)
我刚开始也以为是de,但run了一下:却输出:false,false
public class test {
public static void main (String args[]) {
Integer i = new Integer (42);
Long l = new Long (42);
Double d = new Double (42.0);
System.out.println(i.equals (d));
System.out.println(d.equals (i));
}
}

D:\test>javac test.java

D:\test>java test
false
false
cxl528 2002-10-23
  • 打赏
  • 举报
回复
de

50,503

社区成员

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

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