Skip to content
UPEEC

Object-Oriented Java

Constructors, the four pillars, overloading vs overriding, relationships between classes, generics, reflection and object equality. Classes and objects, inheritance, interfaces and abstract classes and generics have their own pages earlier in this subject.

Easy
Comments 0

This is an overview — pick a sub-topic below.

Sub-topics (14)

Constructors in Java

Special methods that initialise new objects; same name as the class, no return type.

Beginner♥ 0🔖 0💬 0

Polymorphism in Java

A reference of a parent type can point to any subclass, and overridden methods run the subclass version.

Easy♥ 0🔖 0💬 0

Encapsulation in Java

Keep fields private and control access through methods to protect invariants.

Beginner♥ 0🔖 0💬 0

Abstraction in Java

Expose what an object does while hiding how — via interfaces and abstract classes.

Easy♥ 0🔖 0💬 0

Method Overloading

Several methods with the same name but different parameter lists, chosen at compile time.

Beginner♥ 0🔖 0💬 0

Method Overriding

A subclass provides its own version of an inherited method, chosen at run time.

Easy♥ 0🔖 0💬 0

Composition

Build classes from other objects ("has-a") instead of inheriting ("is-a").

Easy♥ 0🔖 0💬 0

Association

A general relationship where objects use or know each other, each with its own lifecycle.

Easy♥ 0🔖 0💬 0

Aggregation

A "whole-part" association where parts can exist independently.

Easy♥ 0🔖 0💬 0

Reflection

Inspect and use classes, methods and fields at run time.

Advanced♥ 0🔖 0💬 0

The Object Class

The root of every class: `equals`, `hashCode`, `toString`, `getClass`, `clone`, `wait`/`notify`.

Easy♥ 0🔖 0💬 0

equals and hashCode

Equal objects must have equal hash codes — override both together.

Intermediate♥ 0🔖 0💬 0

Comparable

Defines a class's natural ordering via `compareTo`.

Easy♥ 0🔖 0💬 0

Comparator

An external ordering object, composable with helper methods.

Easy♥ 0🔖 0💬 0

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.