Skip to content

Java & OOP Basics

27 topics · Stage 1

Complete

OOP concepts5

Java language22

  • 01InterfacesAn interface is a contract. It lists method names and parameters, and implementing classes write the code. Newer Java also allows a few methods with a body.1 min
  • 02Implementing interfaces (implements)When a class implements an interface, it promises to provide a concrete implementation (method body) for every method declared in that interface.1 min
  • 03Abstract classes and inheritanceInheritance means one class is a subtype of another: the child extends the parent and gets its fields and methods. The child can add new ones or override existing methods.2 min
  • 04EncapsulationEncapsulation means keeping an object’s data (state) hidden from the outside and only allowing access through controlled methods.2 min
  • 05ConstructorsA constructor is a block of code that runs when you create an object with new ClassName(...). It has the same name as the class and no return type.1 min
  • 06static and finalstatic means “belongs to the class, not to each object.”2 min
  • 07Method overriding and polymorphismOverriding means a subclass (or a class that implements an interface) provides its own implementation of a method that already exists in the parent or interface.2 min
  • 08GenericsGenerics let you write classes and methods that work with a type you specify later, so the compiler can check types and you avoid casting.1 min
  • 09Exception handlingExceptions are Java’s way of signaling that something went wrong (invalid input, missing resource, unsupported operation, etc.). If not handled, they can stop the program.2 min
  • 10Cloneable and clone()Cloneable is a marker interface in Java (no methods). If a class implements Cloneable, it is allowed to use the default cloning behavior from Object.clone().1 min
  • 11Inner and static nested classesA class defined inside another class is a nested class.1 min
  • 12Dependency injectionDependency injection means a class does not create its dependencies itself. Instead, they are passed in from outside (e.g. via constructor or setter).1 min
  • 13Fluent API and annotationsA fluent API lets you call multiple methods in a row on the same object, usually by having each method return this (the same object).1 min
  • 14EnumsAn enum is a class with a fixed list of instances. You use it when a value can only be one of a few known options, like a direction, a status, or a size.4 min
  • 15equals() and hashCode()equals() decides when two objects are the same value. hashCode() helps HashMap and HashSet find them. Override both.5 min
  • 16Lambdas, functional interfaces and streamsA lambda is a short way to write a function without giving it a name or wrapping it in a class.6 min
  • 17Collections: which one to pickEvery collection in Java sits under one of these interfaces.6 min
  • 18Concurrency basicsAfter an LLD design, the next question is almost always what happens if two users do this at the same time. This note covers the minimum Java tools to answer it.6 min
  • 19Strings and immutabilityWhy String can never change, how the string pool works, when to use StringBuilder, and how to write your own immutable class with defensive copies.9 min
  • 20Memory, pass by value and garbage collectionStack vs heap, why Java is always pass by value, boxing traps like the Integer cache, how garbage collection decides what to free, and how Java apps still leak memory.11 min
  • 21Optional and null handlingWhy null causes so many bugs, how to use Optional well (and where not to), failing fast with requireNonNull, empty collections, and the Null Object pattern.7 min
  • 22Records, sealed classes and pattern matchingModern Java for LLD rounds. Records for value objects, sealed types for a closed set of cases, pattern matching, switch expressions, and when var helps or hurts.9 min