0% found this document useful (0 votes)
3 views

Java Entry Level Written Test

Uploaded by

rownak tahmid
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Java Entry Level Written Test

Uploaded by

rownak tahmid
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Java Entry Level Written Test

30 Questions - 2 hours

1.
String str1 = new String("hello");
String str2 = new String("hello");

I. What will str1 == str2 return? Explain why.


II. What will str1.equals(str2) return? Explain why.

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?

4. What is static and dynamic polymorphism? Explain with examples.

5. Where are these keywords being used? What is the purpose?


final, finally, finalize

6. Write a program to reverse a string in Java.

7. Implement binary search in Java.

8. How do you print a current date(date object) in a specific format(yyyy-MM-dd) in Java?

9. How do you create a functional interface? Create a Foo functional interface with the method
test().

10.
package com.example.programming-interviews;

public class String Programs {

static void main(String[10] args) {


String s = "abc"
System.out.println(s);
}
}
Find five mistakes in the code (Write those mistakes)

11. Explain the difference between an ArrayList and a LinkedList in Java. When would you
use each?

12. Describe the structure of a HashMap. How does it handle collisions?

13. Write a program to filter out even numbers from a list and return the list of odd
numbers. Use Java Streams.

List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6);


// Expected output: [1, 3, 5]

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");
}
}

public static void riskyOperation() {


int result = 10 / 0;
}
}

What will the above code print?

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?

19. What do you mean by ACID property in RDBMS? Explain.

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

101 Human Resources

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.

23. What is dependency injection? Why do we use this?


24. What is the Spring Bean lifecycle?

25. What are the differences between @Controller and @RestController in Spring?

26. What is the purpose of the @Configuration annotation?

27. What is Spring Boot Actuator?

28. What is the use of @Qualifier annotation 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.

You might also like