可学答题网 > 问答 > SCJP程序员认证考试题库
目录: 标题| 题干| 答案| 搜索| 相关
问题

Which of the followi


Which of the following statements are true?() 

  • A The equals() method determines if reference values refer to the same object.
  • B The == operator determines if the contents and type of two separate objects match.
  • C The equals() method returns true only when the contents of two objects match.
  • D The class File overrides equals() to return true if the contents and type of two separate objects  match.
参考答案
参考解析:

严格来说这个问题的答案是不确定的,因为equals()方法是可以被重载的,但是按照java语言的本意来说:如果没有重写(override)新类的equals(),则该方法和 == 操作符一样在两个变量指向同一对象时返回真,但是java推荐的是使用equals()方法来判断两个对象的内容是否一样,就像String类的equals()方法所做的那样:判定两个String对象的内容是否相同,而==操作符返回true的唯一条件是两个变量指向同一对象。从这个意义上来说选择给定的答案。从更严格的意义来说正确答案应该只有D。

分类:SCJP程序员认证考试题库
相关推荐

1、Which of the followi

Which of the following is a true statement when promiscuous mode is enabled on an...

2、Which of the followi

Which of the following accurately represents the functionality of a lightweight access point&...

3、Which of the followi

Which of the following is not a CRS Telephony or Media Subsystem?()AJTAPI BCisco Media CVXML DMRCP ASR EMRCP TTS&e

4、Which of the followi

Which of the following characteristics applies only to OSPFv3 and not to OSPFv2?()ASeveral...

5、Which of the followi

Which of the following four CRS components must be active on a Historical Reporting&#81...

6、Which of the followi

Which of the following are valid modes of accessing the data plane? (Choose all&#8194...