Interview Sets for Screening Java Developers

Introduction

One of the biggest challenges while interviewing Java developers is maintaining consistency across candidates. Many interviewers ask different questions to different candidates, making comparison difficult.

This interview handbook provides:

  • Standardized Interview Sets
  • Core Java Questions
  • Java 8 Questions
  • Spring Boot Questions
  • SQL Questions
  • Programming Exercises
  • Architecture Questions
  • Evaluation Templates
  • Detailed Answers

Each candidate receives:

SectionQuestions
MCQ8
Programming1
SQL1
Architecture1
Total Duration30 Minutes

Candidate Evaluation Sheet

FieldValue
Candidate Name
Experience
Primary Skill
Interview Date
Interviewer
MCQ Score/40
Programming Score/25
SQL Score/15
Architecture Score/20
Total/100
RecommendationHire / Hold / Reject
Comments

INTERVIEW SET 1 – Core Java Fundamentals

MCQs

Q1. What is JVM responsible for?

A. Compiling Java Code

B. Executing Bytecode

C. Creating JAR files

D. Database Connectivity


Q2. Which OOP principle allows code reuse?

A. Polymorphism

B. Encapsulation

C. Inheritance

D. Abstraction


Q3. Which keyword prevents inheritance?

A. private

B. static

C. final

D. abstract


Q4. Which memory area stores local variables?

A. Heap

B. Stack

C. Method Area

D. Constant Pool


Q5. Which collection allows duplicate elements?

A. Set

B. HashSet

C. TreeSet

D. ArrayList


Q6. Which exception is checked?

A. NullPointerException

B. ArithmeticException

C. IOException

D. ArrayIndexOutOfBoundsException


Q7. What is method overloading?

A. Same method name with different parameters

B. Same method name with same parameters

C. Different method names

D. Constructor overriding


Q8. Which access modifier provides maximum visibility?

A. private

B. protected

C. default

D. public


Programming Exercise

Problem Statement

Print a Number Triangle.

Input:

5

Expected Output:

1
12
123
1234
12345

Instructions

  • Use loops only.
  • Do not hardcode output.
  • Explain time complexity.

SQL Question

Employee

emp_id | emp_name | dept_id
1      | John     | 10
2      | Sam      | 20
3      | Alice    | 10

Department

dept_id | dept_name
10      | IT
20      | HR

Question

Write SQL to display:

John  IT
Sam   HR
Alice IT

Architecture Question

Explain JVM architecture and different memory areas.


ANSWERS – SET 1

MCQs

QuestionAnswerExplanation
Q1BJVM executes bytecode generated by javac
Q2CInheritance promotes code reuse
Q3CFinal class cannot be extended
Q4BStack stores local variables and method calls
Q5DArrayList allows duplicates
Q6CIOException is checked
Q7ASame method name, different parameters
Q8DPublic provides widest visibility

Programming Solution

public class Pattern {

    public static void main(String[] args) {

        int n = 5;

        for(int i=1;i<=n;i++) {

            for(int j=1;j<=i;j++) {
                System.out.print(j);
            }

            System.out.println();
        }
    }
}

Complexity

Time: O(N²)

Space: O(1)


SQL Solution

SELECT e.emp_name,
       d.dept_name
FROM Employee e
JOIN Department d
ON e.dept_id = d.dept_id;

Architecture Answer

JVM contains:

  • Heap
  • Stack
  • Method Area
  • Program Counter
  • Native Method Stack

Heap stores objects.

Stack stores method calls and local variables.

Method Area stores class metadata.


Review Sheet – Set 1

AreaScore
Java Core
Programming
SQL
Architecture
Total

INTERVIEW SET 2 – OOP & Collections

MCQs

Q1. Which OOP concept hides implementation details?

A. Inheritance

B. Abstraction

C. Composition

D. Polymorphism


Q2. Can abstract classes have constructors?

A. Yes

B. No


Q3. Which collection automatically sorts elements?

A. ArrayList

B. HashSet

C. TreeSet

D. Vector


Q4. HashMap allows?

A. Duplicate Keys

B. Duplicate Values

C. Sorted Keys

D. Thread Safety


Q5. Which collection maintains insertion order?

A. HashSet

B. TreeSet

C. LinkedHashSet

D. Hashtable


Q6. Runtime polymorphism is achieved using?

A. Method Overloading

B. Method Overriding

C. Constructor Chaining

D. Encapsulation


Q7. Which collection is synchronized?

A. ArrayList

B. HashSet

C. HashMap

D. Vector


Q8. If equals() is overridden, what should also be overridden?

A. compareTo()

B. clone()

C. hashCode()

D. finalize()


Programming Exercise

Problem Statement

Reverse a String without using built-in reverse methods.

Input:

Java8

Output:

8avaJ

Instructions

  • Do not use StringBuilder.reverse().
  • Explain complexity.

SQL Question

Employee

emp_id | dept_id | salary
1      | 10      | 10000
2      | 20      | 15000
3      | 10      | 12000
4      | 20      | 18000

Question

Find maximum salary for each department.


Architecture Question

Interface vs Abstract Class after Java 8.


ANSWERS – SET 2

MCQ Answers:

1-B
2-A
3-C
4-B
5-C
6-B
7-D
8-C

Explanation Highlights

  • TreeSet sorts naturally.
  • HashMap allows duplicate values but not keys.
  • Method overriding gives runtime polymorphism.
  • hashCode() contract must align with equals().

Programming:

String str = "Java8";

for(int i=str.length()-1;i>=0;i--) {
    System.out.print(str.charAt(i));
}

Time Complexity: O(N)

Space Complexity: O(1)


SQL:

SELECT dept_id,
       MAX(salary)
FROM Employee
GROUP BY dept_id;

Architecture:

Interface:

  • Contract
  • Multiple inheritance

Abstract Class:

  • State
  • Constructors
  • Shared implementation

Default methods reduced the gap but did not replace Abstract Classes.


Review Sheet – Set 2

AreaScore
Java Core
Programming
SQL
Architecture
Total

INTERVIEW SET 3 – Java 8 Fundamentals

MCQs

Q1. What is Lambda Expression?

A. Anonymous Function

B. Interface

C. Thread

D. Collection


Q2. Functional Interface contains?

A. One Abstract Method

B. Multiple Abstract Methods

C. No Methods

D. Unlimited Methods


Q3. Which is a Functional Interface?

A. List

B. Runnable

C. Set

D. Map


Q4. Which method creates a Stream?

A. stream()

B. filter()

C. map()

D. collect()


Q5. Which Stream operation is Intermediate?

A. count()

B. collect()

C. filter()

D. forEach()


Q6. Optional helps avoid?

A. Deadlocks

B. NullPointerException

C. Memory Leaks

D. Synchronization


Q7. Which operation transforms data?

A. count()

B. map()

C. collect()

D. forEach()


Q8. CompletableFuture supports?

A. Serialization

B. Reflection

C. Asynchronous Programming

D. Caching


Programming Exercise

Problem Statement

Find frequency of characters.

Input:

banana

Output:

b=1
a=3
n=2

SQL Question

Employee

emp_id | salary
1      | 10000
2      | 15000
3      | 20000
4      | 18000

Find second highest salary.


Architecture Question

Explain Stream API and advantages over loops.


ANSWERS – SET 3

MCQs:

1-A
2-A
3-B
4-A
5-C
6-B
7-B
8-C

Explanations

  • Lambda = anonymous function.
  • Functional interface = one abstract method.
  • map() transforms elements.
  • CompletableFuture supports async programming.

Programming:

Map<Character,Integer> map =
        new HashMap<>();

for(char ch : str.toCharArray()) {

    map.put(ch,
            map.getOrDefault(ch,0)+1);
}

Time: O(N)

Space: O(N)


SQL:

SELECT MAX(salary)
FROM Employee
WHERE salary <
(
  SELECT MAX(salary)
  FROM Employee
);

Architecture:

Benefits:

  • Declarative programming
  • Less boilerplate
  • Easy parallelization
  • Improved readability

Review Sheet – Set 3

AreaScore
Java 8
Programming
SQL
Architecture
Total

INTERVIEW SET 4 – Spring Boot Fundamentals

MCQs

Q1. What does IOC stand for?

A. Internal Object Creation

B. Inversion Of Control

C. Input Output Controller

D. Internet Of Components


Q2. Dependency Injection is performed by?

A. JVM

B. Database

C. Spring Container

D. Tomcat


Q3. Which annotation marks a REST controller?

A. @Controller

B. @Component

C. @Service

D. @RestController


Q4. Default bean scope?

A. Prototype

B. Request

C. Singleton

D. Session


Q5. Purpose of @Autowired?

A. Dependency Injection

B. Logging

C. Security

D. Transactions


Q6. @SpringBootApplication combines how many annotations?

A. 1

B. 2

C. 3

D. 4


Q7. application.properties is used for?

A. External Configuration

B. Logging Only

C. Security Only

D. Testing Only


Q8. Spring Boot Actuator provides?

A. Monitoring

B. Security

C. ORM

D. Scheduling


Programming Exercise

Problem Statement

A palindrome is a word that reads the same forward and backward.

Examples:

madam
racecar
level

Write a Java program to determine whether a given string is a palindrome.

Input:

madam

Output:

Palindrome

SQL Question

Customers

customer_id | customer_name
1           | John
2           | Sam
3           | Alice

Orders

order_id | customer_id
101      | 1
102      | 1
103      | 2

Display all customers and their orders using LEFT JOIN.


Architecture Question

Explain Spring Bean Lifecycle.


ANSWERS – SET 4

MCQs:

1-B
2-C
3-D
4-C
5-A
6-C
7-A
8-A

Programming:

String str = "madam";

String rev = "";

for(int i=str.length()-1;i>=0;i--) {
    rev += str.charAt(i);
}

if(str.equals(rev))
    System.out.println("Palindrome");
else
    System.out.println("Not Palindrome");

Time: O(N)

Space: O(N)

SQL:

SELECT c.customer_name,
       o.order_id
FROM Customers c
LEFT JOIN Orders o
ON c.customer_id=o.customer_id;

Architecture:

Lifecycle:

  1. Bean Instantiation
  2. Dependency Injection
  3. @PostConstruct
  4. Business Usage
  5. @PreDestroy

Review Sheet – Set 4

AreaScore
Spring
Programming
SQL
Architecture
Total

INTERVIEW SET 5 – Design Patterns & Problem Solving

MCQs

Q1. Can interfaces have default methods?

A. Yes

B. No


Q2. Can static methods be overridden?

A. Yes

B. No


Q3. What does equals() compare?

A. Memory Address

B. Object Content

C. JVM Reference

D. Class Loader


Q4. Which pattern encapsulates behavior?

A. Factory

B. Strategy

C. Builder

D. Singleton


Q5. Which pattern creates objects?

A. Factory

B. Observer

C. Adapter

D. Strategy


Q6. Strategy Pattern supports which SOLID principle?

A. OCP

B. SRP

C. ISP

D. LSP


Q7. Major advantage of Microservices?

A. Tight Coupling

B. Independent Deployment

C. Shared Database

D. Single Technology Stack


Q8. Horizontal Scaling means?

A. Bigger Server

B. More Servers

C. Faster CPU

D. Larger JVM


Programming Exercise

Print Reverse Pyramid.

Input:

5

Output:

*********
 *******
  *****
   ***
    *

SQL Question

Employee

emp_id | dept_id
1      | 10
2      | 10
3      | 20
4      | 20
5      | 20

Find employee count department-wise.


Architecture Question

Design a Payment System supporting:

  • Credit Card
  • UPI
  • Wallet

Discuss design patterns.


ANSWERS – SET 5

MCQs:

1-A
2-B
3-B
4-B
5-A
6-A
7-B
8-B

Programming:

for(int i=0;i<n;i++) {

    for(int j=0;j<i;j++)
        System.out.print(" ");

    for(int k=0;k<(2*(n-i))-1;k++)
        System.out.print("*");

    System.out.println();
}

Time: O(N²)

Space: O(1)

SQL:

SELECT dept_id,
       COUNT(*)
FROM Employee
GROUP BY dept_id;

Architecture:

Use:

  • Strategy Pattern for payment behavior
  • Factory Pattern for strategy creation

Benefits:

  • Extensible
  • Open Closed Principle
  • Easy maintenance

Coming Next

Part 2 will contain:

  • Set 6 – JVM & Memory Management
  • Set 7 – Collections Deep Dive
  • Set 8 – Java 8 Streams Advanced
  • Set 9 – Spring Boot & Microservices
  • Set 10 – Architecture & System Design

along with detailed answers, evaluation sheets, and hiring guidance.

Leave a Reply

Your email address will not be published. Required fields are marked *