0% found this document useful (0 votes)
3 views2 pages

Java Interview Cheatsheet

The document is a cheat sheet for Java developer interviews, covering key concepts such as Java features, JVM, JRE, JDK, and differences between various collections like HashMap and ConcurrentHashMap. It also explains functional interfaces, exception types, string handling, streams, garbage collection, and the distinctions between abstract classes and interfaces. Additionally, it highlights Spring Boot's role in simplifying application development and its use in building microservices and REST APIs.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Java Interview Cheatsheet

The document is a cheat sheet for Java developer interviews, covering key concepts such as Java features, JVM, JRE, JDK, and differences between various collections like HashMap and ConcurrentHashMap. It also explains functional interfaces, exception types, string handling, streams, garbage collection, and the distinctions between abstract classes and interfaces. Additionally, it highlights Spring Boot's role in simplifying application development and its use in building microservices and REST APIs.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Developer Interview Cheat Sheet (4 Years

Experience)

Q: What are the main features of Java?


- Object-Oriented: Everything is represented as objects. - Platform Independent: Java bytecode
runs on any platform via JVM. - Robust: Strong memory management, exception handling, and
garbage collection. - Multithreaded: Supports concurrent execution of threads. - Secure: No explicit
pointers, runs in JVM sandbox. - High Performance: JIT compiler optimizes bytecode to native
instructions.

Q: Explain JVM, JRE, and JDK.


- JVM (Java Virtual Machine): Executes Java bytecode, provides portability across platforms. - JRE
(Java Runtime Environment): JVM + core libraries (for running Java apps). - JDK (Java
Development Kit): JRE + compiler + tools (for developing Java apps).

Q: Difference between HashMap and ConcurrentHashMap?


- HashMap: Not synchronized, can be used in single-threaded apps, allows one null key and
multiple null values. - ConcurrentHashMap: Thread-safe, uses internal locking on segments, does
not allow null keys/values, better performance in concurrent scenarios.

Q: What are functional interfaces in Java 8?


- An interface with exactly one abstract method. - Examples: Runnable, Callable, Comparator. -
Java 8 introduced @FunctionalInterface annotation. - Can be used with lambda expressions and
method references.

Q: Explain the difference between checked and unchecked exceptions.


- Checked Exceptions: Verified at compile time, must be handled using try-catch or throws. (e.g.,
IOException, SQLException) - Unchecked Exceptions: Subclass of RuntimeException, occur at
runtime, not required to be handled. (e.g., NullPointerException, ArithmeticException)

Q: What is the difference between String, StringBuilder, and StringBuffer?


- String: Immutable, stored in String pool, new objects created on modification. - StringBuilder:
Mutable, not thread-safe, better performance in single-threaded cases. - StringBuffer: Mutable,
synchronized, thread-safe, slower than StringBuilder.

Q: What are Streams in Java 8?


- A sequence of elements supporting sequential and parallel aggregate operations. - Not a data
structure, works with collections, arrays, or I/O channels. - Supports operations like map(), filter(),
reduce(), collect(). - Example: [Link]().filter(x -> x > 10).collect([Link]())

Q: Explain Garbage Collection in Java.


- Automatic process to reclaim memory by removing unused objects. - Runs inside JVM. -
Generational model: Young, Old, Permanent generations. - Can trigger manually with [Link](),
but not guaranteed.

Q: Difference between Abstract Class and Interface?


- Abstract Class: Can have both abstract and concrete methods, constructors, and state (fields).
Supports single inheritance only. - Interface: Can only have abstract methods (until Java 8 – now
supports default and static methods). Supports multiple inheritance of type.

Q: Explain Spring Boot and why it is used.


- Spring Boot simplifies Java application development by eliminating boilerplate configuration. -
Provides embedded servers (Tomcat/Jetty). - Auto-configuration based on classpath settings. -
Production-ready features: metrics, health checks, externalized configuration. - Used for building
microservices and REST APIs quickly.

You might also like