Object & Wrapper - Day 6 Flashcards

1
Q

Object class

A

Implicit super class of all classes.

Commonly used methods of object class: equals(), hashCode(), toString()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Equals method

A

.equals() compares objects to check for equality

Needs overrideing in the class for it to work for different requirements.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

hashCode()

A

Uses object’s data to generate hash value (32 bit integer)

If two objects are equal, hashCode() must produce the same int value for the objects

^ NOT ALWAYS EQUAL IF HASHCODE IS THE SAME

uses formula to generate integer

Equals and hashcode must be overridden together

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

toString()

A

Returns a textual representation of an object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Wrapper class

A

Convert data types into objects in Java programming.

Boolean, Character, Integer, Long, Float and Double classes

Help represent the primitive data types as objects.

Belong to java.lang package

How well did you know this?
1
Not at all
2
3
4
5
Perfectly