Java Entry Level Written Test
Java Entry Level Written Test
30 Questions - 2 hours
1.
String str1 = new String("hello");
String str2 = new String("hello");
2. What are the basic four principles of OOP? Explain each of them with an example.
3. Explain the concept of Exception Handling in Java. What is the difference between checked
and unchecked exceptions? Can you name one checked and one unchecked exception?
9. How do you create a functional interface? Create a Foo functional interface with the method
test().
10.
package com.example.programming-interviews;
11. Explain the difference between an ArrayList and a LinkedList in Java. When would you
use each?
13. Write a program to filter out even numbers from a list and return the list of odd
numbers. Use Java Streams.
14.
public class ExceptionHierarchyExample {
public static void main(String[] args) {
try {
riskyOperation();
} catch (NullPointerException e) {
System.out.println("Caught NullPointerException");
} catch (ArithmeticException e) {
System.out.println("Caught ArithmeticException");
} catch (RuntimeException e) {
System.out.println("Caught RuntimeException");
} catch (Exception e) {
System.out.println("Caught Exception");
}
}
15. Explain JVM Memory model from high level with a diagram.
16. How can you create Thread? Explain the lifecycle of a thread in Java.
17. What is Race Condition and Deadlock in Thread? How can you avoid Race condition?
18. Explain the difference between String, StringBuilder, and StringBuffer. When
would you use each, and why?
21.
Employees
EmployeeID Name DepartmentID
1 Saheer 101
2 Bob 102
3 Charlie 103
4 Rownak 104
5 Edward 105
6 Alice 106
Departments
DepartmentID
102 IT
103 Marketing
104 Sales
105 Finance
● Write a query to get each employee's name along with their department name.
● List all departments and the number of employees in each department, including
departments with no employees.
22. How would you optimize a slow-running query in SQL? Mention some strategies.
25. What are the differences between @Controller and @RestController in Spring?
29. What command initializes a Git repository in a project? How do you create a new branch in
Git, and how do you switch to it?
30. Have you heard about Design pattern in java? What is the purpose of Design pattern?
Explain Singleton design pattern with code.