Member-only story
Java + Spring Boot + Microservices Interview Questions with Examples
6 min read 2 days ago
🔹 Section 1: Core Java (10 Questions)
- What is the difference between
==
and.equals()
in Java?
String a = new String("test");
String b = new String("test");
System.out.println(a == b); // false (reference comparison)
System.out.println(a.equals(b)); // true (value comparison)
== compares references; .equals() compares values (unless overridden).
2. What is the difference between HashMap and Hashtable?
- HashMap is not synchronized (faster, not thread-safe)
- Hashtable is synchronized (thread-safe, but slower)
3. What is the purpose of the final
, finally
, and finalize()
?
final
: Prevent modificationfinally
: Always executes after try-catchfinalize()
: Called by GC before object removal
4. What is the difference between abstract class and interface?
abstract class Animal {
abstract void makeSound();
}
interface Walkable {
void walk();
}
Abstract class can have constructors and state; interface is contract only.
5. What are functional interfaces and give an example?
@FunctionalInterface
interface Greeting {
void sayHello(String name);
}