Home / Advanced Java: Streams, Concurrency, JVM and Spring / Interview questions · हिन्दी
Advanced Java interview questions
11 questions from the Advanced Java: Streams, Concurrency, JVM and Spring course, each with the correct answer and an explanation. Try to answer before you open the answer.
Module 2: Concurrency 1. What are virtual threads best suited for? Many concurrent blocking I/O tasks CPU-bound number crunching only Replacing the garbage collector Compiling code Show answer Answer: Many concurrent blocking I/O tasks
They make blocking I/O cheap so you can scale thread-per-task code.
Lesson: Virtual Threads (Java 21)
Module 5: Enterprise Java, Spring & REST 2. A client sends valid credentials but tries to delete another user's order. What status code fits best? 401 Unauthorized 404 Not Found 403 Forbidden 500 Internal Server Error Show answer Answer: 403 Forbidden
401 means missing/invalid credentials; here the client is authenticated but not allowed to act on this resource — that's 403.
Lesson: API Status Codes & Error Handling
Module 7: Design Patterns 3. What problem does the Observer pattern primarily solve? Guaranteeing only one instance of a class exists Letting an object notify many interested parties about a change without depending on their concrete types Building complex objects step by step Choosing which concrete class to instantiate at runtime Show answer Answer: Letting an object notify many interested parties about a change without depending on their concrete types
That's Singleton (0), Builder (2), and Factory (3) respectively — Observer is about one-to-many change notification.
Lesson: Observer Pattern
Module 10: Cloud-Native Java 4. Which feature lets you pass behaviour as an argument? Static imports Annotations Lambda expressions Packages Show answer Answer: Lambda expressions
Lambdas implement functional interfaces.
Lesson: Reactive Programming Intro
5. What does Stream.map do? Filters elements Terminates the stream Sorts keys Transforms each element Show answer Answer: Transforms each element
map applies a function to each element.
Lesson: Reactive Programming Intro
6. Which class safely handles absent values? Optional Object Void Number Show answer Answer: Optional
Optional makes missing values explicit.
Lesson: Reactive Programming Intro
7. What does happens-before guarantee? Faster code One thread's writes are visible to another No exceptions Automatic locks Show answer Answer: One thread's writes are visible to another
It defines memory visibility between threads.
Lesson: Reactive Programming Intro
8. Which tool manages thread pools? Scanner StringBuilder ExecutorService Properties Show answer Answer: ExecutorService
Executors decouple tasks from threads.
Lesson: Reactive Programming Intro
9. Which Spring concept supplies dependencies to your classes? Reflection only JSP Servlets Dependency injection Show answer Answer: Dependency injection
The IoC container wires beans together.
Lesson: Reactive Programming Intro
10. Why hash passwords with bcrypt? So plain text is never stored To make them shorter To speed up login To allow decryption Show answer Answer: So plain text is never stored
Hashing protects users if data leaks.
Lesson: Reactive Programming Intro
11. What do virtual threads make cheap? CPU-bound loops Blocking I/O concurrency Memory leaks Compilation Show answer Answer: Blocking I/O concurrency
The JVM parks blocked virtual threads.
Lesson: Reactive Programming Intro
← Back to the course