Tricky Java Interview Questions Series: Release 2

Abhijit Jadhav
2 min readJul 13, 2022

We are back with the second release of tricky interview questions for a quick interview revision and preparation. You can go through Release 1 here.

Photo by Maranda Vandergriff on Unsplash

11. What is the difference between these two?

List<Integer> list = new ArrayList<>(10);
List<Integer> list = new ArrayList<>();

12. What are the different ways to break a Singleton pattern?

13. Will the below code compile if you create an object of Child in the main class.

class Parent {
private void doSomething() throws FileNotFoundException {}
}
class Child extends Parent {
private void doSomething() throws IOException {}
}

14. What is a Co variant return type?

15. How the instanceof method violates the symmetric contract of the equals method during inheritance in the working of the hashtable?

16. Write a stream API code to find the duplicate elements without using the Set?

list.stream().filter(i -> Collections.frequency(list,i) > 1).collect(Collectors.toSet)

17. How is spring security intercepting your request and what are the different interceptors available in java.

18. What is Client Side Discovery and what are its pros and cons in the application?

19. What status code you will return if the requested resource is not found during a GET request to your REST endpoint?

20. What is the volatile keyword in java?

You can go through more just tricky interview questions in Release 3 here and don't forget to follow me for more such questions.

--

--

Abhijit Jadhav

Full Stack Java Developer and AI Enthusiast loves to build scalable application with latest tech stack