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

Java Questions

The document contains a comprehensive list of interview questions covering various topics in Java, including OOP concepts, design patterns, multithreading, Spring Boot, microservices, and data structures. It addresses practical scenarios, theoretical concepts, and specific Java features, providing a wide range of questions for assessing knowledge in Java programming and related technologies. The questions also touch upon performance considerations, memory management, and best practices in software development.

Uploaded by

saloni.kohli.ab
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Java Questions

The document contains a comprehensive list of interview questions covering various topics in Java, including OOP concepts, design patterns, multithreading, Spring Boot, microservices, and data structures. It addresses practical scenarios, theoretical concepts, and specific Java features, providing a wide range of questions for assessing knowledge in Java programming and related technologies. The questions also touch upon performance considerations, memory management, and best practices in software development.

Uploaded by

saloni.kohli.ab
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

1: OOPs Concepts

2: Why need Encapsulation ?


HashSet and TreeSet

3: use of java design pattern and what is , Abstract , factory , builder , proxy
4: what is use of Externalisation and what is use of it
5: What is serialisation
6: What is atomic integers any use case of it.?
7: what is use Comparator and what is use of equals and hascode..
8:Suppose if you have Student class so do you need to overwrite equals and hascode.
, if yes why or if not why not ?
9: what is sigma four
10 what is coundownlach
11 what is cyclic barrier
12 : What is executorframwork ? and how to create ?
13: explain producer and consumer problem and use of synchronisation wait notify
notifyall
14 : What is dedlock in multithreading and how to prevent from thi
15: what is new in java 8 in terms of hasmap?
16: Any practical scenario when we will use Array list , Linked list , Hasmap and
Concurrent hash map,hashset,

17: What is use of FI and use in java


18: How to create own FI .
19 : use of Stream API with example and 2 3 methods of it

RMQ Question:

1: What is use of RMQ?


2: What is advantage of it over kafka?
3: What is Topic and what is Exchange ?
4 : how to configure RMQ?

Spring Boot : Interview Question.

1: What is advantage of Spring Boot over Spring ?


2: What are main annotation for Spring boot?
What is use of @primary use
4: how to do dependancy injection is Spring Boot?
5: How to configured ome then one schema in spring Boot?

Microservice Interview QUESTION :


1: What is micro servise and what is use of it ?
2: how to create in microserice ?
3: what is diffrence between restFull service and micro service ?
4: how to ensure security of micro service ?
5: How micro service can comunicate with each other ?
6: What if one micro service will down how to manage this scenario?
7: what is RMQ role in microservice communication
8: tell me for any hostile portal , how you will create microservisces? and how
many microsece
9: how to manage transactionality in Mircoservise (basically asking of SAGA
pattern )
10 How to deploy and where to deploy Microccs?
11: what is use of service discovery in MS?
12: What is API gatway and how to configured ?

1) Difference between Enumerations and Iterator?


2) How to sort HashMap in java ?
3) Can we do one thread is reading and another thread modifying in array list
explain in details ?
4) Two thread can access if suppose a method is declared synchronized
5) What is concurrentHashmap in java ?
6) What is copyOnWriteArrayList in java ?
7)Can two thread access synchronized method symentenously ?
8)What is Abstract Factory Design Pattern ?
9)What is Difference between prototype and request scope ?
10)Self Join to get employee manager name
11)What is difference between @Auto wired & @Qualifier ?
12) How to kill process in Linux ?
13) How to access a file from child of child directory ?
14) Linux command for get active process ?

1)How to find the nearest date compared to a given date in a collection.


2)Difference between map and flat map with an example.
3)Elaborate Association, Aggregation and composition with live examples.
4)How to find the mid element of a list without traversal?
5)Code to reverse a linked list.
6)How to sort a collection by a date?
7)Best collection for a given scenario:
3 students
3 subjects
N times attended the exam

Output required : max number per subject and total no of exams that the student
attended.

8)WAP to mirror of a Binary search tree?


9)On what factors hashcode of an object would get changed?
10)WAP to print �My name is Rachit� 10 times by 4 threads printing each word
respectively.
11)Scenarios doing calculation/manipulation (apart from the ordering ) in the
comparable or comparator method.
12)Unix commands to kill and find the specific process.
13)How grep works in unix?
14)Unix - search content in a file from the last.

1) I have two class Human and Heart, Whenever a human class is created Heart class
should be created. what kind of association is this represent and how to implement
it.
2) internal structure of Hashmap
3) I have a class
Employee {
name,
doj
}

i store an object with name="sachin" & dob. and stored it as a key. later on i
changed that name="somthing else" what would happen,
if a do get, set in map and how to prevent it.

4) I have a multiple students e.g.


StudentA -> <Subject_Math> -> Marks<70>
<Subject_English> -
> Marks<20>
<Subject_Science> -
> Marks<60>

StudentB -> <Subject_Math> -> Marks<30>


<Subject_English> -
> Marks<20>
<Subject_Science> -
> Marks<60>

StudentC -> <Subject_Math> -> Marks<30>


<Subject_English> -
> Marks<20>
<Subject_Science> -
> Marks<60>

which collection you use to print all the students with highest marks (consider
space and time complexity)

5) I have a list of employee

Employee {
name,
doj
}

find the next employee with passed doj.

6) how celling and floor methods internally works.


7)Volatile keyword
8) What is the use of AtomicInteger,AtomicBoolean like classes while you hava
Volatile.
9) 3 threads printing each word "My Name Sachin" 10 times.
10) What is Collections.synchronizedMap what is the internal implementation.
11) Find the middle element in LinkedList without traversal.

Have you ever faced OutOfMemory exception? How to analyse and fix it?
What is difference between Heap Dump and Thread Dump?
Difference between PermGen and MetaSpace.
What are different java command line arguments to tune JVM?
There are multiple tasks A, B, C .. Y, which can run in parallel and there is a
task Z which need to be started after all the tasks are completed. How to achieve
this?
How CompletableFuture works? Write Code.
Ways to Create Thread. What is executorService.shutdown()?
How to stop a Thread?
What tools you have used for code management and building the projects?

1.What is default method in java 8? And why it has been introduced?


2.HashMap changes in Java 8?
3.How to get nth Node from last of the LinkedList without knowing the length of
LinkedList?
4.Java Memory Model in Java 8?
5.Difference between ConcurrentHashMap and Collections.synchronizedMap()? And how
synchronizedMap() works internally.
6.Scenario based questions:-
Class Employee{
int id;
String name;
}

In HashMap, id will remain same and shouldn�t be modified but name should keep
changing as per the requirement.
So how will you manage Employee class in HashMap?

7.HashMap<Integer, String> map = new HashMap<>();


map.put(1,�b�);
map.put(2, �a�);
map.put(3, �c�);

Sort the map using values?

8.Difference between HashMap and Hashtable?


9.How the infinite loop occurs in HashMap? What conditions/logic make it infinite?
10.Synchronized(obj1){
Obj2.wait();
}
What will be happen in this scenario? If we are locking obj1 and calling wait
method on different object?
11.Difference between PermGem and Metaspace?

1.Consider you have 9 batteries 1,2,3....9. It contains mix of 5 working and 4 dead
batteries.
what will be the approach so that combination of two working batteries can be
find out in minimum no. of steps?

2. What is AtomicInteger ? Explain how internally it works ?

3. Which Design pattern you recently used ? Cross Questioning on Singleton Design
Pattern. How to make it work
well in multi-threaded environment ?
what is preferrable whether to synchronize getInstance method or using
synchronize block?
Then cross questioning on that again.

4. What is concurrentHashMap ? How segment locking works when two thread


simultaneously read and write a segment ?

5. There is a File in which we are updating a sequence of number. This file is


getting updated every 5 hrs with new number added in last.
How will you find the largest number in sequence in a given time ?

6. What is Consumer-Producer Problem ? Is there any way without using


synchronization we can resolve it ?

7. What arrays.sort uses internally ? Time Complexity of merge Sort ?

1. Volatile and transient

2. Bubble sort and complexities

3. Time complexity of adding an element in arraylist.

4. Difference between concurrentHashMap and Collections. synchronizedMap

5. Different kind of threadPools

6. Wait and Notify for project specific scenario

7. Difference between synchronised method/block. And in synchronised block which


object has lock?

8. Producer and consumer problem and it�s solution


9. Static and Synchronised method has what level of lock?

10. Can I pass mutable class as HashMap key?

11. Equals and hashcode

12. What are enums? Can we have our own methods in enums? Can enums be passed as
keys in HashMaps?

13. What are Generics? What is ? in generics and <T,T> in generics

14. String and StringBuffer output questions.

15. Why is String immutable?

16. Super and Sub class based output questions

17. Sorting of HashMap

18. Polymorphism(Runtime polymorphism)

19. Is java call by value / call by reference? Then an output question was given
based on this concept only.

20. HashMap get and put methods implementations.

You might also like