Java/Spring/Hibernate/DB interview questions
ü
What is the generic data type used for password
ü
Why do we use getter and setter methods in a
class?
ü
What is heap memory and what is stack memory
ü
Difference b/w JVM and JRE?
ü
How hashcode is calculated?
ü
Write immutable class
ü
If immutable class has Date as field, can't it
be changed?
ü
Why password should be used as char array, what
is the demerit of using as String?
ü
What is intern method in String?
ü
Advantages of immutable class
ü
String class uses being immutable
ü
Advantages of Object class making abstract.
ü
How will you implement in your application to
send notification of email to team member if some exception raised.
ü
What are the different ways and strategies used
in your application to handle exception?
ü
How you are handling custom exception.
ü
Explain OOPs and how you used in your real time
application.
ü
Batch Processing in Java
ü
Explain polymorphism and give me a real time
scenario where you used overloading and overriding in your application.
ü
Two different name but same class type
declaration what happen?
ü
Advantages of Object class making abstract.
ü What
are the steps we need to do when we use User defined keys in Map? If not
Override what happen.
ü
When you will go for abstract and explain the
real time scenario you used in your application so far.
ü
Try – catch - Finally with return
ü
If we have return statements in both catch and
finally what will be output.
ü
When we use Runtime Exception and compile time
Exception.
ü
When we use finally block.
ü
When we use catch and throws with scenario.
ü
Define Oops
ü
What is serialization and what is the use for
this.
ü
Define final, finally, finalize.
ü
Explain Exception Handling. Types
ü
Difference between Abstract and Interface class
and when go for interface and abstract class.
ü
Difference between interface and abstract class
in java
ü
Can we use non-static member in interface.
ü
Is filenotfoundexception is a checked o
unchecked exception.
ü
What’s the difference between error and
exception in java?
ü Tell me what are the runtime
exception present in java?
ü
Which design pattern string pool uses
Input and Output
ü
What is serializable and their methods?
ü
If we have parent class as non-serlizable and
child class as serializable how can we achieve this?
ü
Using write off /read off method
ü
Marshalling and Un-Marshalling.
Collection
ü
Design the following scenario without using the
Blocking Queue classes Folder path has 1000 files. 5 thread has to process the
files with only 5 files at a time.
ü
How the following scenario have be designed 1
daemon and 2 user thread. Daemon thread has to start execution after the 2 user
thread completes. Or Application server has to start after the 2 application
finished loaded.
ü
Concurrent Map vs. Hash Map vs. Synchronized Map
ü
Suppose we have a collection where key is a user
defined object. Will we get the values stored against them in return?
ü
Infinite loop in Hash Map
ü
What is load factor in collections?
ü
We have a Hash Map with employee data. EmpId is
the key and Emp Name is the value. How can we sort the Hashmap based on key
values if two or more employees have same name
ü
If I want to remove one object in array list
how?
ü
How hashmap internally works and what is the
enhancement in Java8 for hashmap
ü
How memory allocated for linked list and
arraylist
ü
How to make arraylist synchronized
ü
Arraylist class in concurrent java package
ü
Hash map internal implementation
ü
Tree Map?
ü
Difference between Array list and Linked list?
ü
If I want to remove one object in list which one
is better Array list or linked list?
ü
We have key as manager and value as list how can
we generate custom hashcode for each key value pair?
ü
When we use Comparable and comparator with
scenario.
ü
Define hashcode() and equal() methods hashmap
ü
Difference between Arraylist and Linkedlist, Set
and List
ü
Suppose in Hashmap if we put duplicate key then
what will happen...Is it showing any compilation or runtime exception.
ü
FailFast and FailSafe? While iterating a
HashMap, how one thread will come to know if some other thread is modifying the
same HashMap?
ü Difference between set &
HashSet
ü
Difference between ArrayList & HashMap
ü
Tree Set & Hashset Map difference
ü
If answering sorting due to extending sortedset
class... how it internally this API works??
ü
Can we insert null key in hashmap, concurrent
hashmap
Concurrent
ü What
is concurrent HashMap?
ü
Internal working of concurrent Hash Map
ü
Performance issues of concurrent Hash Map
ü
Comparator and comparable interface?
ü
Why concurrent hash map replace hashtable?
Inter-thread communication
ü
Difference between Synchronized block and
Synchronized method?
ü What
difference is between notify and notify
All().
ü
What are the diff. state of thread?
ü
If we won’t call start() method in thread and
call run() method .then what will happen?
ü Why
used yield and join () method in java
Thread
ü
What is cyclic barrier, countdownlatch?
ü
What is connection pool? How can we get a
connection pool of 6 threads?
ü
Consider a scenario in which 1-10 numbers should
be printed sequentially and we have only 3 threads. Thread t1 should print 1,
t2 should print 2, t3 should print 3, and t4 should print 4, so on
ü
How can we use singleton class in multithreading
ü
How to create thread pool.
ü
Calculation for finding thread pool count.
ü
Tell me a scenario where you are using
multithreading in your last project.
ü
How to write the code for the following
scenario. Suppose in a thread we have to print 1, 2,3,4,5 .so how to print the
these value one by one using multi-threading in java
ü
Odd & even printing of the numbers, in
multithreaded
ü
Thread. Sleep somethere if answered , then if printing numbers based on single input in
multi-threaded environment, lock on input resource is there then how would you
make other thread to read them.
ü
What happens during Thread.sleep
ü
Performance tuning implementation in your
application using threads
ü
Difference with object lock using thread.sleep
and object.wait method
ü
How thread pool is created and what are
different type of thread pool are there.
Design Pattern
ü
Singleton
ü
If we do lazy initialize of object in method of
single ton, will it be thread safe? How to implement thread safety?
ü
Can we make singleton class thread-safe or not? If yes how
ü
Design patterns in Java?
ü 9) In singleton if I don't remove setters still
will I can achieve?? Private
constructor, synchronized get instance...
ü
Design pattern singleton, factory and abstract
factory and Structural Patterns.
ü
Factory pattern explain?
Spring Batch:
ü
What is spring batch?
ü
Spring Batch – real time scenario of reading
single Large File reading and processing and writing back to File using
Threading approach. Expected spring batch partitioning.
ü
We have 50K records which need to be processed
which will take more time, instead I want to run in in parallel in batch of 10K
each using springs? How to achieve this?
o Spring
batch how we create partition and how it is handled.
Spring
ü
Inheritance mapping in spring?
ü
Bean Scopes in spring?
ü
How will you inject prototype bean into a
singleton one?
ü
We have different bean id as same class in
spring, but not mentioned any scope (default as taken as singleton) it would be
return same object or different object?
ü Spring scope? Explain it?
ü
Base class for transaction management in spring
ü
Bean factories in spring
ü
How to create custom bean factory in spring
ü
How to invoke a bean in Spring
ü
Why do we go for spring?
ü
Explain about DI and IOC? Is there any specific
difference between them?
ü
Can we use spring without MVC if so how.
ü
Scope of beans in spring
ü
What is singleton and its example?
ü
What is AOC and how to achieve?
ü
What’s spring? What’s is loose coupling
ü
What’s difference between ioc and dependency
injections?
ü
What’s difference between bean factory and application
context
ü
How to map(handle) client side request in
spring.
ü
Difference between constructor based and setter
/getter injection
ü
What are the scope present in spring?
ü
How to inject prototype bean in spring
ü
What’s the life cycle of spring beans?
ü
In spring where the objects is located?
ü
Singleton class vs Singleton bean.
ü
What will be the sequence of loading in Spring, if
we have a class injected inside another class?
ü
How a class is instantiated in spring. Which
technique it uses (reflection)
ü
Spring default scope? Other scopes in spring??
ü
<bean id="1"
class="a.java">
ü
<bean id="2"
class="a.java"> is it still singleton working here???
ü
Not alias means...? How will you implement customized
singleton in spring?
ü
How to implement above singleton in spring config.xml
ü
Lifecycle management of spring
ü
What parent keyword does in spring?
ü
Which is better constructor or setter for bean
creation.
ü
How we can load multiple context file in spring.
Spring Integration (data, mvc, webservice)
ü
How to integrate Struts, Hibernate and Spring
Previous Project Questions
ü
Tell about the current project and the
technologies used in the project.
ü
Brief introduction about yourself, technology
worked so far, previous project and roles and responsibility of your previous
project
Datastructure
ü
How to solve following scenario
ü
The End node of linked list is pointed to any of
middle node, it will lead to infinite times while iteration
ü
How to get the exact middle element from linked
list in faster way
ü
Which is best Sorting Algorithm and why
ü
Given a linked List of no fixed size (end
element is not known), find the middle element in one iteration?
ü
What is Stack Working?
ü
How will u find the max element in Stack?
Scenario?
Database:
ü
How will you maintain different DB connectivity
in your application on need basics?
ü
Group by and having query uses and how it works
ü
Table with 3 columns having values, write a
single query to return different values for specific expression- expecting
decode not case condition.
ü
Give any 5 performance measured you follow in
DB. Also give the same for Java.
ü
What is union & union all in SQL?
ü
14) Say the output for the following queries if
employee table has employee id with 1, 2, 3, 4 5
Select e.eid, e,
ename from EMPLOYEE e where e.eid=1
-
Select e.eid, e,
ename from EMPLOYEE e where e.eid=2
ü 15)
Say the output for the following queries if employee table has employee id with
1, 2, 3, 4, and 5
Select e.eid, e,
ename from EMPLOYEE e where e.eid=1
-
Select e.eid, e,
ename from EMPLOYEE e where e.eid=1
ü
How you are setting values in sp’s for the
select statement.
ü
How you are handling exception in sp’s.
ü
Explain Outer Joins (Left, Right and Full ).
ü
Why we use Sequence.
ü
How to fetch data from one schema to others.
ü
Difference between truncate and delete?
ü
If I delete the records what will happen inside
the database? Where it will store the deleted records in database?
ü
How to get 2nd highest salary in oracle
ü
Table T1 is having only one column like col1.
The values like below.
Col1
10
20
5
18
ü
Display the highest value without using any
inbuilt function?
ü
Table T1 having data like
EmpID DeptID Salary
1 10 10000
2 10 20000
3 20 30000
4 20 40000
ü Display
the output like EmpID, DeptID is same but Salary column display the that
department Highest Salary.
ü
What is a pragma autonomous transaction? Where
we can use the pragma autonomous transaction? Use of pragma autonomous
transaction? Give the one real time example?
ü
What are the mandatory fields in anonymous
block?
ü
One query taking time for execution. How you can
improve the performance of that query? Which steps you can follow for better
performance?
ü
What is the redo log buffer?
ü
Design the data model
ü
Subject and Teachers are there.
ü
One teacher can teach multiple subjects.
ü
One subject can taught by multiple teachers.
ü
In this scenario how many tables is required?
And which columns are the primary keys and foreign keys having? Explain the all
tables?
Process:
ü
What SDLC process have you used previously and
explain.
ü
How you are testing your application.
ü
Is there any specific tool used for testing.
ü
After development completed how your testing
process followed.
ü
How your SIT testing done after your changes
moved to SIT.
ü
Have you used Jenkins?
ü
Suppose your development completed and moves to
UAT or preproduction and now your stakeholder requested for additional changes
for the same feature, how you will handle this case.
ü What is SonarQube?
ü
How jobs are created in Jenkins
Struts:
ü Struts2.0
flow.
Servlet
ü
Difference between forward and redirect
ü
Difference between get and post.
Web service:
ü
Difference between SOAP and RESTFUL Web services
and when will you choose it
ü
How to expose EJB as a web service
ü
Which tool used for WSDL generation and testing
Hibernate
ü
When to choose Hibernate and iBatis
ü
Difference between load and get in Hibernate
ü
Steps to make an entity class for a table in
Hibernate
ü
Types of generator in Hibernate
ü
Persist, SaveOrUpdate and merge use in Hibernate
ü
How to use entity class in Hibernate
ü
What are various key areas worked on hibernate.
ü
What is the advantage of using JDBC template and
what are the technique and methods used so far.
ü
How you mapping tables in hibernate
ü
What are the type of cache in hibernate.
ü
What is lazy loading?
ü
What is cascade in hibernate
ü
How to create class (POJO) of table in hibernate
ü
How to create primary key in hibernate using
hibernate
ü
One to many mapping in hibernate using
annotation
ü
What is Criteria interface in hibernate
ü
Difference between get and load, Merge, update
and save
ü
Load and get.
ü
What are the types of inheritance models in
Hibernate and how they work?
JQuery
ü
How to invoke server side code in JQuery
ü
Scope of variables in JQuery
ü
If I want to refresh a particular part of a page
rather than entire page then how request will be handled in JQuery
Scenario based question:
ü
There are 100 doors. While going ahead all the
doors should be opened and while coming back all the doors should be closed.
And also I can reach 25th, 26th door without opening 24th door. How to
implement in java
ü If
my class having 5 attributes upon wic 1 unique & 4 normal on what basis
will you design hashcode override method?? If unique attribute please justify
your explanation??
ü
If singleton object is serialized!! First is it
possible??
ü Next
- if deserializing will I get same object??? Next if my application running in
JVM and am deserailzing won't it override my singleton object?? Explanations at
each of above point.
ü There
are 3 thread and all thread print number one after another. How this can be
achieved.
Comments
Post a Comment