zuai-logo
zuai-logo
  1. AP Computer Science A
FlashcardFlashcardStudy GuideStudy GuideQuestion BankQuestion BankGlossaryGlossary

Glossary

.

.equals() method

Criticality: 3

The `.equals()` method is used to compare the *content* or attributes of two objects, determining if they are logically equivalent based on the class's definition.

Example:

When comparing two Book objects, book1.*equals*(book2) would return true if they have the same title and author, regardless of their memory location.

=

== operator

Criticality: 3

In Java, the `==` operator checks if two object references point to the exact same object in memory, comparing their memory addresses.

Example:

If car1 and car2 are two separate Car objects, car1 *==* car2 will be false even if they have identical attributes, because they are distinct objects in memory.

C

Content equality

Criticality: 3

A type of object equality that checks if the internal data or attributes of two distinct objects are the same, typically determined by the `.equals()` method's implementation.

Example:

Two Song objects might have different memory addresses but exhibit content equality if their title, artist, and duration are identical.

O

Object equality

Criticality: 3

The concept of determining if two objects are considered the same, which can be based on whether they are the exact same instance in memory (reference equality) or if their internal states are identical (content equality).

Example:

Deciding if two Student objects represent the same student (based on ID) or just two students with the same name involves understanding object equality.

Overriding .equals()

Criticality: 3

The process of providing a custom implementation for the `.equals()` method in a class to define what it means for two objects of that specific class to be logically equal based on their attributes.

Example:

A Product class might override .equals() to consider two products equal if they have the same product ID, even if other attributes like price or description differ.

P

Primitive types

Criticality: 2

Basic data types in Java (e.g., `int`, `double`, `boolean`, `char`) that store direct values rather than references to objects, and are compared using the `==` operator.

Example:

Variables like int age = 20; or boolean isActive = true; store their values directly and are compared using the *==* operator because they are primitive types.

R

Reference equality

Criticality: 3

A type of object equality that specifically checks if two variables refer to the exact same object instance in memory, meaning they point to the same memory address.

Example:

If listA and listB both point to the same ArrayList object, then listA *==* listB would be true, indicating reference equality.

S

String pool

Criticality: 2

A special area in Java's memory where `String` literals are stored and reused to optimize memory usage, preventing duplicate `String` objects for identical literal values.

Example:

When you declare String s1 = "Java"; and String s2 = "Java";, both s1 and s2 will refer to the same object in the string pool.