MCQs
Q1. Which JVM memory area stores objects?
A. Stack
B. Heap
C. Method Area
D. Program Counter
Q2. What is Garbage Collection?
A. Memory Allocation
B. Memory Cleanup of Unused Objects
C. Object Creation
D. Stack Cleanup
Q3. Which exception is unchecked?
A. SQLException
B. IOException
C. ClassNotFoundException
D. NullPointerException
Q4. Which keyword is used to explicitly throw an exception?
A. throws
B. throw
C. catch
D. finally
Q5. What is the purpose of finally block?
A. Catch exceptions
B. Create exceptions
C. Execute cleanup code
D. Handle JVM shutdown
Q6. Can a finally block execute if return is present in try?
A. No
B. Yes
Q7. What causes OutOfMemoryError?
A. Stack Overflow
B. Heap Exhaustion
C. Database Failure
D. Network Timeout
Q8. Which memory area stores method calls?
A. Heap
B. Stack
C. Method Area
D. Native Heap
Programming Exercise
Problem Statement
A number is called an Armstrong Number if the sum of cubes of its digits equals the original number.
Example:
153 = 1³ + 5³ + 3³
Write a Java program to check whether a number is Armstrong or not.
Input:
153
Output:
Armstrong Number
SQL Question
Employee
emp_id | emp_name | salary
1 | John | 10000
2 | Sam | 20000
3 | Alice | 30000
4 | Bob | 15000
Find employees earning more than average salary.
Architecture Question
Explain Heap vs Stack memory and common memory-related issues in Java applications.
ANSWERS – SET 6
MCQs
1-B
2-B
3-D
4-B
5-C
6-B
7-B
8-B
Explanations
- Heap stores objects.
- GC reclaims unreachable objects.
- NullPointerException is unchecked.
- throw throws exception; throws declares exception.
- finally is used for resource cleanup.
- finally executes even if return exists.
- OutOfMemoryError usually indicates heap exhaustion.
- Stack stores method calls and local variables.
Programming Solution
public class Armstrong {
public static void main(String[] args) {
int num = 153;
int temp = num;
int sum = 0;
while(temp > 0) {
int digit = temp % 10;
sum += digit * digit * digit;
temp /= 10;
}
if(sum == num)
System.out.println("Armstrong Number");
else
System.out.println("Not Armstrong Number");
}
}
Complexity:
Time: O(D)
Space: O(1)
Where D = Number of digits.
SQL
SELECT *
FROM Employee
WHERE salary >
(
SELECT AVG(salary)
FROM Employee
);
Architecture Answer
Heap:
- Stores objects
- Shared across threads
Stack:
- Stores local variables
- Thread specific
Common Issues:
- Memory Leak
- OutOfMemoryError
- StackOverflowError
REVIEW SHEET – SET 6
| Area | Score |
|---|---|
| JVM | |
| Programming | |
| SQL | |
| Architecture | |
| Total |
INTERVIEW SET 7 – Collections Framework Deep Dive
MCQs
Q1. Which collection stores unique elements?
A. List
B. ArrayList
C. Set
D. Vector
Q2. Which collection provides O(1) average lookup?
A. TreeMap
B. HashMap
C. LinkedList
D. TreeSet
Q3. TreeMap internally uses?
A. Hash Table
B. Array
C. Red Black Tree
D. Linked List
Q4. Which collection maintains insertion order?
A. HashMap
B. TreeMap
C. LinkedHashMap
D. Hashtable
Q5. Hashtable allows null keys?
A. Yes
B. No
Q6. ConcurrentHashMap is primarily used for?
A. Sorting
B. Thread Safety
C. Serialization
D. Reflection
Q7. Which interface is parent of List?
A. Map
B. Collection
C. Iterable
D. Queue
Q8. Which collection is best for FIFO?
A. Stack
B. PriorityQueue
C. Queue
D. TreeSet
Programming Exercise
Count duplicate words in a sentence.
Input:
java spring java boot spring java
Output:
java=3
spring=2
boot=1
SQL Question
Employee
emp_id | emp_name | dept_id
1 | John | 10
2 | Sam | 20
3 | Alice | 10
4 | Bob | 10
Find departments having more than 2 employees.
Architecture Question
HashMap vs ConcurrentHashMap. Explain use cases.
ANSWERS – SET 7
MCQs:
1-C
2-B
3-C
4-C
5-B
6-B
7-B
8-C
Programming
String input =
"java spring java boot spring java";
String[] words = input.split(" ");
Map<String,Integer> map =
new HashMap<>();
for(String word : words) {
map.put(word,
map.getOrDefault(word,0)+1);
}
Time: O(N)
Space: O(N)
SQL
SELECT dept_id,
COUNT(*)
FROM Employee
GROUP BY dept_id
HAVING COUNT(*) > 2;
Architecture
HashMap:
- Not Thread Safe
- Faster
ConcurrentHashMap:
- Thread Safe
- Segment/Bucket level locking
- Suitable for concurrent applications
REVIEW SHEET – SET 7
| Area | Score |
|---|---|
| Collections | |
| Programming | |
| SQL | |
| Architecture | |
| Total |
INTERVIEW SET 8 – Java 8 Streams & Functional Programming
MCQs
Q1. What is a Functional Interface?
A. Multiple Abstract Methods
B. One Abstract Method
C. No Methods
D. Only Default Methods
Q2. Which annotation marks Functional Interface?
A. @FunctionalInterface
B. @Override
C. @Component
D. @Bean
Q3. Which stream operation transforms data?
A. filter()
B. count()
C. map()
D. collect()
Q4. Which operation removes elements?
A. map()
B. collect()
C. filter()
D. reduce()
Q5. reduce() is used for?
A. Aggregation
B. Filtering
C. Sorting
D. Mapping
Q6. Which operation is terminal?
A. filter()
B. map()
C. sorted()
D. collect()
Q7. What is Method Reference?
A. Lambda Shortcut
B. Interface
C. Collection
D. Annotation
Q8. Optional prevents?
A. Deadlocks
B. Memory Leaks
C. NullPointerException
D. Serialization Errors
Programming Exercise
Using Java 8 Streams:
Find all even numbers from a list and return their squares.
Input:
1,2,3,4,5,6
Output:
4,16,36
SQL Question
Orders
order_id | customer_id | amount
101 | 1 | 500
102 | 1 | 700
103 | 2 | 300
104 | 2 | 900
Find total amount spent by each customer.
Architecture Question
Advantages and disadvantages of Stream API.
ANSWERS – SET 8
MCQs:
1-B
2-A
3-C
4-C
5-A
6-D
7-A
8-C
Programming
List<Integer> result =
numbers.stream()
.filter(n -> n % 2 == 0)
.map(n -> n * n)
.collect(Collectors.toList());
Time: O(N)
Space: O(N)
SQL
SELECT customer_id,
SUM(amount)
FROM Orders
GROUP BY customer_id;
Architecture
Advantages:
- Readable
- Functional style
- Parallel processing
Disadvantages:
- Debugging harder
- May not suit all use cases
REVIEW SHEET – SET 8
| Area | Score |
|---|---|
| Java 8 | |
| Programming | |
| SQL | |
| Architecture | |
| Total |
INTERVIEW SET 9 – Spring Boot & Microservices
MCQs
Q1. What is IOC?
A. Inversion of Control
B. Internal Object Control
C. Input Output Controller
D. Internet Object Controller
Q2. Which annotation injects dependency?
A. @Bean
B. @Autowired
C. @Primary
D. @Value
Q3. Which annotation creates REST APIs?
A. @Controller
B. @Repository
C. @RestController
D. @Service
Q4. Default bean scope?
A. Prototype
B. Singleton
C. Session
D. Request
Q5. What is API Gateway used for?
A. Database Access
B. Service Entry Point
C. Logging
D. Caching
Q6. Which protocol is commonly used between microservices?
A. SMTP
B. FTP
C. HTTP/REST
D. POP3
Q7. What is Service Discovery?
A. Finding Databases
B. Locating Microservices
C. Logging Services
D. Security Service
Q8. Spring Boot Actuator is used for?
A. Monitoring
B. ORM
C. Security
D. Scheduling
Programming Exercise
Given a list of Employee objects:
Return employee names sorted by salary descending.
SQL Question
Employee
emp_id | emp_name | dept_id | salary
Find highest paid employee in each department.
Architecture Question
Explain Microservice Architecture and common challenges.
ANSWERS – SET 9
MCQs:
1-A
2-B
3-C
4-B
5-B
6-C
7-B
8-A
Programming
employees.stream()
.sorted(
Comparator.comparing(
Employee::getSalary)
.reversed())
.map(Employee::getName)
.collect(Collectors.toList());
SQL
SELECT dept_id,
MAX(salary)
FROM Employee
GROUP BY dept_id;
Architecture
Challenges:
- Distributed Transactions
- Service Discovery
- Monitoring
- Logging
- Fault Tolerance
Advantages:
- Independent Deployment
- Independent Scaling
REVIEW SHEET – SET 9
| Area | Score |
|---|---|
| Spring | |
| Programming | |
| SQL | |
| Architecture | |
| Total |
INTERVIEW SET 10 – Design Patterns & System Design
MCQs
Q1. Factory Pattern is used for?
A. Object Creation
B. Behavior Selection
C. Event Handling
D. Caching
Q2. Strategy Pattern is used for?
A. Object Creation
B. Encapsulating Algorithms
C. Logging
D. Serialization
Q3. Singleton ensures?
A. Multiple Instances
B. Single Instance
C. Multiple Threads
D. Caching
Q4. Which SOLID principle does Strategy support?
A. OCP
B. SRP
C. ISP
D. LSP
Q5. Observer Pattern is used in?
A. Event Notification
B. Object Creation
C. Logging
D. Serialization
Q6. Which pattern is heavily used by Spring?
A. Singleton
B. Factory
C. Dependency Injection
D. All of the Above
Q7. Horizontal scaling means?
A. Bigger Server
B. More Servers
C. Faster CPU
D. Bigger JVM
Q8. Load Balancer is used for?
A. Security
B. Request Distribution
C. Logging
D. Database Access
Programming Exercise
Print Fibonacci Series up to N terms.
Input:
10
Output:
0 1 1 2 3 5 8 13 21 34
SQL Question
Employee
emp_id | emp_name | manager_id
1 | John | NULL
2 | Sam | 1
3 | Alice | 1
4 | Bob | 2
Display employee name along with manager name.
Architecture Question
Design a Notification System supporting:
- SMS
- Push Notifications
Discuss design patterns and scalability considerations.
ANSWERS – SET 10
MCQs:
1-A
2-B
3-B
4-A
5-A
6-D
7-B
8-B
Programming
int a = 0;
int b = 1;
for(int i=1;i<=10;i++) {
System.out.print(a + " ");
int c = a + b;
a = b;
b = c;
}
Time: O(N)
Space: O(1)
SQL
SELECT e.emp_name,
m.emp_name AS manager_name
FROM Employee e
LEFT JOIN Employee m
ON e.manager_id = m.emp_id;
Architecture
Design Patterns:
- Strategy Pattern
- Factory Pattern
Scalability:
- Queue based delivery
- Retry mechanism
- DLQ
- Horizontal scaling
- Notification status tracking
FINAL INTERVIEW EVALUATION GUIDE
| Score | Recommendation |
|---|---|
| 90 – 100 | Strong Hire |
| 80 – 89 | Hire |
| 70 – 79 | Conditional Hire |
| 60 – 69 | Borderline |
| Below 60 | Reject |
Skills Matrix
| Skill | Weight |
|---|---|
| Core Java | High |
| OOP | High |
| Collections | High |
| Java 8 | High |
| Spring Boot | High |
| SQL | Medium |
| Design Patterns | Medium |
| Architecture | High |
| Problem Solving | High |
Strong Hire Indicators
- Explains JVM memory confidently
- Understands Java 8 beyond syntax
- Can write joins and group by queries
- Knows Spring IOC and DI clearly
- Uses appropriate design patterns
- Explains time and space complexity
- Demonstrates architecture thinking
Red Flags
- Cannot differentiate HashMap and ConcurrentHashMap
- Weak understanding of Streams
- No knowledge of Spring Bean lifecycle
- Unable to write JOIN queries
- Memorized design patterns without use cases
- Cannot explain complexity of solutions