Java

Object-Oriented Programming

34 lessons in this section of the Java tutorial. Work through them in order, or jump to the one you need.

  1. 1.OOP Concepts

    Object-Oriented Programming (OOP) is a programming paradigm that organises software around objects — self-contained units that combine data (fields) and behaviour…

  2. 2.Classes

    A class is the fundamental building block of Java.

  3. 3.Objects

    An object is a runtime instance of a class.

  4. 4.Object Creation

    Object creation in Java is the process of allocating memory, initialising fields, and running constructor logic to bring an object into existence.

  5. 5.Default Constructor

    A default constructor is a constructor that takes no parameters.

  6. 6.Parameterized Constructor

    A parameterized constructor is a constructor that accepts one or more arguments, allowing the caller to supply initial values for the object's fields at the moment of…

  7. 7.Constructor Overloading

    Constructor overloading means defining multiple constructors in the same class, each with a different parameter list.

  8. 8.Copy Constructor

    A copy constructor creates a new object as a duplicate of an existing object of the same type.

  9. 9.this Keyword

    The this keyword in Java is a reference to the current object — the instance on which a method or constructor is currently executing.

  10. 10.static Keyword

    The static keyword declares that a member belongs to the class itself rather than to any specific instance of the class.

  11. 11.final Keyword

    The final keyword in Java means that something cannot be changed after it is first set.

  12. 12.Access Modifiers

    Access modifiers control the visibility of classes, fields, constructors, and methods.

  13. 13.Encapsulation

    Encapsulation is the principle of bundling data and the methods that operate on that data into a single unit — the class — and controlling access to the internals…

  14. 14.Single Inheritance

    Single inheritance is the most fundamental relationship between classes in Java — one class extends exactly one other class, inheriting its fields and methods.

  15. 15.Multilevel Inheritance

    Multilevel inheritance forms a chain of classes where each class extends the one above it — A extends B, B extends C, creating a three-level hierarchy.

  16. 16.Hierarchical Inheritance

    Hierarchical inheritance occurs when multiple classes extend a single superclass — one parent, many children.

  17. 17.Method Overriding

    Method overriding occurs when a subclass provides its own implementation of a method that is already defined in its superclass.

  18. 18.super Keyword

    The super keyword in Java is a reference to the superclass portion of the current object.

  19. 19.Compile-time Polymorphism

    Compile-time polymorphism, also called static polymorphism or early binding, is the form of polymorphism where the method to be called is determined by the compiler at…

  20. 20.Runtime Polymorphism

    Runtime polymorphism, also called dynamic polymorphism or late binding, is the form of polymorphism where the method implementation to execute is determined at runtime…

  21. 21.Abstraction

    Abstraction is the process of exposing only the essential features of a concept while hiding the irrelevant implementation details.

  22. 22.Abstract Class

    An abstract class is a class that cannot be instantiated — it exists only to be extended.

  23. 23.Interface

    An interface is a pure contract — a named set of method signatures that any implementing class promises to support.

  24. 24.Multiple Inheritance using Interface

    Java does not allow a class to extend more than one class, but a class can implement any number of interfaces.

  25. 25.Association

    Association is a relationship between two classes where one class uses or interacts with another, but neither class owns the other and both can exist independently.

  26. 26.Aggregation

    Aggregation is a specialised form of association that represents a whole-part relationship where the part can exist independently of the whole.

  27. 27.Composition

    Composition is the strongest form of the has-a relationship, where the whole object creates, owns, and is entirely responsible for the lifecycle of its parts.

  28. 28.Object Class

    java.lang.Object is the root of the entire Java class hierarchy.

  29. 29.Anonymous Object

    An anonymous object is an object that is created and used without being assigned to a named reference variable.

  30. 30.Initialization Blocks

    Initialization blocks are code blocks that run during object or class creation, supplementing constructors and field initializers.

  31. 31.Nested Classes

    A nested class is a class declared inside another class.

  32. 32.Inner Classes

    An inner class is a non-static class declared inside another class.

  33. 33.Anonymous Inner Classes

    An anonymous inner class is a class that is declared and instantiated in a single expression.

  34. 34.Static Nested Classes

    A static nested class is a class declared with the static modifier inside another class.