Java Programming - Objects and Collections - Discussion
|
|
|
|
Read more:"When ambition ends, happiness begins."
- (Proverb)
|
| 2. |
Which class does not override the equals() and hashCode() methods, inheriting them directly from class Object? |
| [A]. |
java.lang.String | [B]. |
java.lang.Double | | [C]. |
java.lang.StringBuffer | [D]. |
java.lang.Character |
Answer: Option D
Explanation:
java.lang.StringBuffer is the only class in the list that uses the default methods provided by class Object.
|
|
Vidya said:
(Sun, Jul 18, 2010 05:07:46 AM)
|
|
| |
| can u give me the clear discription? |
|
Firat said:
(Tue, Feb 7, 2012 07:19:30 PM)
|
|
| |
| Other classes are wrapper classes and override equals() and hashCode() methods. The StringBuffer does not override these methods. |
|
Sarfaraz Ahamad said:
(Mon, May 14, 2012 02:31:46 PM)
|
|
| |
| But String class is not Wrapper class. |
|
Pankaj Kalra said:
(Tue, Jul 3, 2012 10:51:47 PM)
|
|
| |
| Why string buffer or string builder not override these 2 mehtods ? |
|
Ghost said:
(Mon, Nov 26, 2012 02:33:11 PM)
|
|
| |
@Sarfaraz Ahamad.
All wrapper classes and String class overrides the equals() and hashCode().
@Pankaj Kalra.
string buffer or string builder are not classes .
The classes are StringBuffer and StringBuilder. Please follow java naming conventions. |
|
|