Posts in 2024
  • Design Pattern

    Thursday, June 13, 2024 in Java Interview Questions

    Design Pattern Singleton Pattern A creational pattern that restricts the instantiation of a class to a single instance eg. beans in IoC Container Decorator Pattern A structural pattern that allows behavior to be added to an individual object, …

    Read more

  • SOLID Principle

    Thursday, June 13, 2024 in Java Interview Questions

    SOLID Principle Single Responsibility Principle A class should have only one reason to change Open Closed Principle Software entities should be open for extension, but closed for modification Liskov Substitution Principle Objects of a superclass …

    Read more

  • I/O

    Thursday, June 13, 2024 in Java Interview Questions

    I/O Java I/O is built around the concept of streams, which are sequences of data Type Byte Streams InputStream and its subclasses OutputStream and its subclasses Character Streams Reader and its subclasses Writer and its subclasses Buffered streams …

    Read more

  • Multithreading

    Thursday, June 13, 2024 in Java Interview Questions

    Multithreading Multithreading is a Java feature that allows concurrent execution of two or more threads for maximum utilization of the CPU Process vs Thread A process is an executing program. It has its own memory space and resources A thread is a …

    Read more

  • Functional Interface

    Thursday, June 13, 2024 in Java Interview Questions

    Functional Interface An interface that contains exactly one abstract method @FunctionalInterface Used to mark an interface as a functional interface Usage with Lambda Expressions Lambda expressions provide a simple way to implement functional …

    Read more

  • Stream

    Thursday, June 13, 2024 in Java Interview Questions

    Stream An abstraction that allows you to process sequences of elements in a functional style Stream Operations Intermediate Operations eg. filter Terminal Operations eg. toList public class Main { public static void main(String[] args) { …

    Read more

  • Generic

    Thursday, June 13, 2024 in Java Interview Questions

    Generic Generics enable types (classes and interfaces) to be parameters when defining classes, interfaces, and methods Pros Stronger type checks at compile time No casting needed Ability to implement generic algorithms Declare Generics Generic class …

    Read more

  • Checked Exceptions vs Unchecked Exceptions

    Thursday, June 13, 2024 in Java Interview Questions

    Checked Exceptions vs Unchecked Exceptions Checked Exceptions Unchecked Exceptions Definition Exceptions that are checked at compile-time Exceptions that occur at runtime and are not checked at compile-time Handling Requirement Must be either caught …

    Read more

  • == vs equals vs hashCode

    Thursday, June 13, 2024 in Java Interview Questions

    == vs equals vs hashCode == equals hashCode Definition Compares references for objects, values for primitives Compares the contents of two objects Returns a hash code value for the object Good Practice Always override equals() when a class’s …

    Read more

  • String vs StringBuilder vs StringBuffer

    Thursday, June 13, 2024 in Java Interview Questions

    String vs StringBuilder vs StringBuffer String StringBuilder StringBuffer Mutability Immutable Mutable Mutable Thread Safety Thread-safe Not thread-safe Thread-safe Use Case Suitable for values that won’t change Best for strings that are …

    Read more