1/61
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Object-Oriented Programming (OOP)
A programming paradigm based on designing objects that interact with each other to model a problem.
Object
An entity that has state (properties) and behavior (actions).
State (of an object)
The properties of an object, represented by fields (variables).
Behavior (of an object)
The actions an object can perform, defined by methods.
Class
A blueprint or contract for constructing objects of the same type.
Instance
An object that is constructed according to the blueprint of a class.
Constructor
A special method that creates instances of a class. Its name must be identical to the class name and it has no return type.
new operator
The keyword used to invoke a constructor and create a new instance of a class.
this keyword
A reserved keyword that references the current object whose constructor or method is being invoked.
Shadowing
When a local variable or parameter has the same name as an instance field, hiding the instance field.
Default Constructor
A no-argument constructor that Java automatically provides ONLY if you do not write any constructors for the class.
Constructor Overloading
Defining multiple constructors in the same class with different parameter lists.
Constructor Chaining
When a constructor invokes another constructor of the same class using this(...). The this(...) call must be the first line of the constructor.
Instance Field
A variable that describes the state of a specific instance. Each object has its own copy of an instance field.
Static Field
A variable that belongs to the entire class rather than a specific instance. All instances share a single copy.
Instance Method
A method that describes the behavior of a specific instance. It can access both instance and static data.
Static Method
A method that belongs to an entire class. It can only access static data and cannot access instance data directly.
Encapsulation
The practice of preventing users from directly accessing and modifying an object's instance data, typically by making fields private and providing public methods (getters/setters) for access.
public access modifier
Members are visible to all classes everywhere.
private access modifier
Members are visible only within the class they are declared in.
Getter (Accessor)
A public method that allows users to access the value of a private instance field.
Setter (Mutator)
A public method that allows users to change the value of a private instance field, often including validation logic.
Aliasing
Occurs when multiple reference variables point to the same object in memory.
Shallow Copy
Copying only the reference to an object, which results in aliasing.
Deep Copy
Creating an entirely new instance with the same state as the original object to prevent aliasing.
Copy Constructor
A constructor that takes an object of the same type as its parameter to create a deep copy of that object.
Wrapper Class
A class that represents a primitive data type as an object (e.g., Integer for int, Double for double).
Autoboxing
The automatic conversion that Java makes between a primitive type and its corresponding wrapper class.
Autounboxing
The automatic conversion that Java makes from a wrapper class to its corresponding primitive type.
Inheritance
The process of deriving a new class (subclass) by extending an existing class (superclass).
Subclass (Child Class)
A class that extends an existing class.
Superclass (Parent Class)
The class from which a child class extends.
extends keyword
Used in a class declaration to establish an 'is a' inheritance relationship.
What a subclass inherits
All accessible fields and methods from its superclass.
What a subclass does NOT inherit
Constructors and private members of the superclass.
Single Inheritance
In Java, a child class can have only one direct parent class.
Object Class
The root of the class hierarchy in Java. Every class extends Object, either directly or indirectly.
super keyword
Used in a subclass to access fields, methods, and constructors from its superclass.
super(...)
A call to a superclass's constructor. It must be the first line of a subclass's constructor.
Method Overriding
When a subclass provides a specific implementation for a method that it inherits from a superclass. The method signature must be identical.
@Override Annotation
An annotation that tells the compiler to check if a method properly overrides a superclass method. It is good practice but not required.
Method Overloading
When a class has multiple methods with the same name but different parameter lists.
protected visibility modifier
Visible to all classes in the same package and all subclasses, regardless of their package.
default (package-private) visibility modifier
Visible only to all classes in the same package.
Javadocs
Special comments written above a class, field, or method that are used to generate API documentation.
Overriding equals()
Implementing the equals(Object other) method to check for object state equality rather than reference equality.
equals() Method Contract
The five rules an equals() implementation must follow: reflexive, symmetric, transitive, consistent, and x.equals(null) must be false.
hashCode() Method
Returns an integer representation of an object.
hashCode() Method Contract
1. If x.equals(y) is true, then x.hashCode() must equal y.hashCode(). 2. If x.hashCode() equals y.hashCode(), x.equals(y) is not necessarily true.
Overriding toString()
Implementing the toString() method to return a meaningful, concise, and informative string representation of an object's state.
Abstract Class
A class that is declared with the abstract keyword and cannot be instantiated. It can be extended by subclasses.
Abstract Method
A method declared with the abstract keyword and has no implementation (no method body). It must be contained within an abstract class.
Concrete Class
A class that is not abstract. A concrete subclass of an abstract class must provide an implementation for all inherited abstract methods.
Polymorphism
Literally 'many forms'; the ability of a reference variable to refer to an object of its own declared type or any of its subtypes.
Static Type
The declared type of a reference variable, which is determined at compile-time and never changes.
Dynamic Type
The actual type of the object that a reference variable points to, which is determined at run-time and can change.
Dynamic Binding
The process where the JVM determines at run-time which implementation of an overridden method to invoke, based on the object's dynamic type.
Typecasting
The process of converting a reference from one type to another.
Upcasting
Casting a reference from a subtype to a supertype (e.g., Animal a = new Dog();). This is always safe and will always compile and run.
Downcasting
Casting a reference from a supertype to a subtype (e.g., Dog d = (Dog) animal;). This may cause a ClassCastException at runtime if the object's dynamic type is not compatible.
Sidecasting
Attempting to cast between two unrelated types in a hierarchy (e.g., sibling classes like Dog to Cat). This will always cause a compile error.
ClassCastException
A runtime exception thrown when an invalid downcast is attempted.