Category: Java

Internal Working of Java HashMap

  • June 20, 2025
  • No Comments

What is Java HashMap? Working Explained with Example Java HashMap is a data structure that stores data in key-value pairs, allowing efficient retrieval, insertion, and deletion of values based on their keys. It uses hashing to map keys to buckets, enabling fast access. How HashMap Works Key-Value Pairs: Each entry consists of a unique key […]

Top Java8 Stream Grouping by Interview Questions with examples

  • June 20, 2025
  • No Comments

1. How do you group strings by their length? Map<Integer, List<String>> grouped = list.stream()   .collect(Collectors.groupingBy(String::length)); 2. How do you group numbers by even and odd? Map<String, List<Integer>> grouped = numbers.stream()   .collect(Collectors.groupingBy(n -> n % 2 == 0 ? “Even” : “Odd”)); 3. How do you group employees by department? Map<String, List<Employee>> grouped = employees.stream()   .collect(Collectors.groupingBy(Employee::getDepartment)); […]

Top Java8 Streams Interview Questions

  • June 20, 2025
  • No Comments

1. How do you filter strings that start with a specific letter? List<String> names = Arrays.asList(“Alice”, “Bob”, “Amanda”, “Brian”); List<String> filtered = names.stream()   .filter(name -> name.startsWith(“A”))   .collect(Collectors.toList()); 2. How do you convert a list of strings to a map with string length as key? List<String> words = Arrays.asList(“Java”, “Stream”, “Lambda”); Map<Integer, String> map = words.stream() […]

Top 15 Java8 Interview Questions for Experienced Developer

  • June 20, 2025
  • No Comments

1. What is a functional interface in Java 8? A functional interface has exactly one abstract method. It can have multiple default or static methods. Example: Runnable, Comparator, or custom: @FunctionalInterfaceinterface MyFunc { void execute(); } 2. What is a lambda expression? A lambda expression provides a concise way to represent an anonymous function. Example: […]

Top 25 Java Interview Questions for Experienced Developer

  • June 20, 2025
  • No Comments

1. What is the difference between abstract classes and interfaces in Java? Abstract classes can have both abstract and concrete methods, while interfaces can only have abstract methods (until Java 8, which introduced default and static methods). A class can implement multiple interfaces but only extend one abstract class. 2. How does Java handle memory […]

  • 1
  • 2