Glossary
Implicitly called
Refers to a constructor being automatically invoked by the Java compiler when a class's constructor is called and no explicit superclass constructor is specified. [23, 33, 34]
Example:
If your Car
class doesn't extend
another class, its constructor will implicitly call the Object
class constructor before its own code runs. [23]
Object class
The `Object` class is the superclass of all other classes, arrays, and data types in Java, providing fundamental properties and methods common to all objects. [1]
Example:
When you create a Dog
class, it automatically inherits from the Object class, even if you don't explicitly write extends Object
.
Override (methods)
The act of providing a specific implementation for a method that is already defined in a superclass, allowing a subclass to change or extend its behavior while maintaining the same method signature. [7, 8, 10, 12, 18]
Example:
A Car
class might override the start()
method inherited from a Vehicle
class to include specific engine ignition logic. [7]
equals() method
A method inherited from the `Object` class that determines if two objects are considered equal to each other based on whether they have the same properties or content. [1, 4, 16, 25]
Example:
To check if two Point
objects, p1
and p2
, represent the same coordinates, you would use p1.*equals*(p2)
instead of p1 == p2
. [16]
hash code
An integer value returned by the `hashCode()` method, used to represent an object's memory location or a unique identifier, especially for efficient storage in hash-based data structures. [20, 35, 36]
Example:
When adding a custom Book
object to a HashSet
, Java uses its hash code to quickly determine where to store it. [35]
hashCode() method
A method inherited from the `Object` class that returns an integer representing the memory location or a unique identifier of an object, often based on its properties. [6, 19, 22, 32]
Example:
If you have two Student
objects with identical names and IDs, their hashCode() method should return the same integer value. [31]
java.lang package
A fundamental Java package that contains core classes, including the `Object` class, which are automatically imported into every Java program. [1, 5, 14, 24]
Example:
The String
class, used for text manipulation, is also part of the java.lang package, meaning you don't need an import
statement to use it.
toString() method
A method inherited from the `Object` class that returns a string representation of the object, typically used for debugging or displaying object information. [1, 2, 17, 19, 21]
Example:
When you print a Date
object directly using System.out.println(myDate)
, Java automatically calls its toString() method to get a readable output. [2]