0% found this document useful (0 votes)
121 views26 pages

Interview Questions

The document contains a comprehensive list of interview questions for various technical roles, focusing on Java, Hibernate, Spring, and general programming concepts. It includes questions on topics such as exception handling, collections, multithreading, and RESTful services, as well as practical coding scenarios. Additionally, it covers advanced topics like Java 8 features, design patterns, and project management inquiries relevant to interviews at companies like HCL and Siemens.

Uploaded by

madhu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views26 pages

Interview Questions

The document contains a comprehensive list of interview questions for various technical roles, focusing on Java, Hibernate, Spring, and general programming concepts. It includes questions on topics such as exception handling, collections, multithreading, and RESTful services, as well as practical coding scenarios. Additionally, it covers advanced topics like Java 8 features, design patterns, and project management inquiries relevant to interviews at companies like HCL and Siemens.

Uploaded by

madhu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 26

Interview Questions Asked In HCL(Telephonic Round)

[Link] to put class in hash map?


[Link] exceptions?(how u will write)
[Link](total details?)
[Link] to iterate database values?
5. what is jndi and explain?
[Link](how u will deploy application in weblogic?
Hiebrnate
[Link] interfaces?
[Link] queries?
[Link] u will change oracle to mysql ?
[Link] to eliminate duplicate values?
spring
1. spring ioc?
[Link]? how u implementd?
[Link] and constructor injection ?what u implemented in u r project?
[Link] to load optional beans?
[Link] of beans?
General
1. static where u used in ur projects?
[Link] hash map can u take key as object?
[Link] map(can hash map key allow duplicates)?
[Link] used in u r project?
[Link] are the packages u used in ur projects?
[Link] set?
[Link] u will eliminate duplicate values from a table?
[Link] and singleton difference?
[Link] on start up?
[Link] boxing and unboxing?

Some interview questions collect from other friends try to practice.

1)Immutable Object is thread safe ?


2)i have two thread one thread need to read data from file and another thread need to write that data in
another file ?
3)by using wait and notify methods need to print even and odd number ?
4)i have 9 users and i have 3 passwords so here how to share these 3 passwords with those 9 users ?
5)I have one integer[] ar={10,20,30,40,10,5,46,30}with some elements so how to remove dulicate elemnts
with this array without using collectionc?
6)I have 2 Strings like String s1="hello world &&@" and String s2="hai sriman sir #@#" so here with these
two Strings i want to remove common elements with out using collections?
7)I have one String like String s="i am a java developer" for this String i want to count how many times
each word is repeated without using regulor expressions ?
8)I have one hashMap object with this object i want to display only repeated values means suppose if you
have one hashmap it contans 1 "a",2 "b", 3 "c" 4 "d" 5 "a", 6 "b", 7 "a" with this hashmap i want to display
only repeated key and value pair ?
9)i have one arraylist object it contans some elements so here i want to display only duplicates please write
the logic ?
10)In my application end user as part of search he is entered String like "amaz#$#%n" so here how you will
replace with those special characters with some space (i got this question in one of the top MNC) ?

interview question in siemens


second round all question are real time try to practice
Interview Questions in Siemens
First round
Core Java:
1. What is exception?
2. What is checked and unchecked exception?
3. Which one u prefer to handle exception try-catch or throws
4. In your project how u handle the exception in which layer and how u map
5. Which collection u used in your project write some pseudo code
6. Difference between HashMap and HashTable
7. If 2 thread try to access my collection Object at same time then is there any problem? If yes how can I
handle this?
8. What is synchronization, and what are the various places where we can use it
9. What is static keyword, where we have to prefer that keyword and why?
10. What is the difference between static block and static method?
11. Cani access an instance field from static context?
12. Cani call a static method through the object reference?
13. Cani declare a class as private?
14. HashMap internal works?
15. programme: ihave one string 9845321067 I have to sort the string in reverse order o/p:-9876543210
without using any predefined method
16. What is polymorphism give one example?
Hibernate:
1. If JDBC is there why hibernate?
2. CanI reuse the session? If yes how if no then what is the problem?
3. What is the difference between level-1 and level-2 cache?
4. Difference between get and load?
5. Difference between update and merge?
6. What is the state of object?
7. What is the lazy attribute and how it works?
8. How u configure data Source and name of the data Source?
Spring:
1. What is dependency injection?
2. Whatis the spring MVC annotation you used in your project?
3. Explain the MVC flow relate with your project architecture?
4. for every request I have to trace the IP address of user note before control will come to the my controller
:(

class I want to trace)


5. What is AOP?
6. What is the difference between join point and point cut?
7. What is the difference between interceptor and around advice in spring AOP?
8. Can we access stored procedure through spring?
9. CanI write 2 times init() method in bean?
10. In my application unused bean is there I don't want to instantiate that bean how can I do?

Second round project manager)


:(

1. What you know about Siemens?


2. Why you prefer to attend interview here in weekends other interview is going on?
3. Why you want to look for change?
4. Briefyourself?
5. Give your project summary?
6. Where you used web servicein your project and how?
7. If your resource will modify the code then it will impact to client then how can you manage
8. By accessing web services if you will get exception then how can I handle it?
9. Difference between rest and soap?
10. How request will forward through soap give explanation?
9. They will give one scenario and u has to tell in this situation what you have to use rest or soap with valid
reason
10. How can you get the resource URI via mail or any other source?
11. Rest did you apply any security in your project ,if no then it can be access by any other person or not if
person was know your URI
12. How you call your resource by using spring give the complete architecture.
13. What are the basic requirement to developed rest resource brief this.
14. Did u ever get a chance to write WSDL?
15. Explain the WSDLwith document-wrapped approach
16. What is the difference between serialization and externalization?
17. Write the procedure to serialize the object
18 what are the method present in serializable interface
19. What is marker interface?
20. What is the difference between serialization and web services cause in both the concept we are
exposing our business object over the network
21. Write down a singleton class
22. How can I restrict that no one can serialize my Singleton class object
23. Is my singleton class can be super class for other classes
24. How can I restricted that no one can be make IS-A relationship with my class
25. What is classCastException give one example and how to resolve it?
26. Did you ever face NullPointerException in your project then how can you handle it.
27. Which server you used and which format you used to package your application
28. How you deploy the code
29. If you are accessing other class and that class have some logical mistake then who will handle? And
how u will know that logic was written by whom
[Link]:
publicclass A {
String name;
public A(String name) {
[Link] = name;
}
}
publicclassBextends A{
}
Here can I instantiate B class
31. Whatis the build tool you used give some overall view.
32. Which bug tracking tool you used and how testing team report about bug
33. Howcode review will be happed?
34. What the topics you are discussing in scrum meeting and how much time your scrum meeting
duration?
35. Your scrum master is onsite people or your Company person who is in onsite.

1, What is the contract between hashcode() and equal()?How it works

nterview Questions:
[Link] architecture?
[Link] flow?
[Link] out all the annotations in spring?
[Link] are all the annotations you used in your project on restful services?
[Link] hibernate use of cascade and inverse?
[Link] level cache? second level cache in hibernate?
[Link] is diff b/w arraylist and linkedlist?
[Link] you explain the internal flow of hashmap?
[Link] is the diff b/w hashmap and hashtable?
[Link] b/w array and arraylist?
[Link] b/w arraylist and vector?
[Link] your project where you used cuncurrent hashmap?
[Link] is java annoying?
[Link] b/w callable interface adn future interface in concurrent package?
[Link] loaders?
[Link] can you take list into map?
[Link] can you take map into list?
[Link] you will get ClassNotFoundException and NoClassDefFoundError?
[Link] you implement exception handling in your project?
[Link] you implement multi-threading in your project?
[Link] are all the design patterens you oberved in spring?
[Link] design patters you used in your project?
[Link] are all the critial situations you come across in your project?
[Link] wait() placed in object class ? why not it is placed in Thread class?
[Link] is use of intern() in spring?
[Link] is diff b/w String str="xyz"; and String str2= new String("xyz");
[Link] about java architectue?
[Link] about jvm architecture?
[Link] base queries?
30.i have a compeny table in remote database. by using rest i need to get the table data and print into a
file?
[Link] to read book pages on online library by using bookid or author id(by using restful services)?
32.i have a table in remote database, how to update the data in that table using rest?
[Link] b/w rest and web(soap)?
[Link] methodolgy?
[Link] to create web-services project and spring project using mavan?
[Link] is diff b/w throw and throws?
[Link] you tell me java8 features?
[Link] are all the contents in wsdl?
[Link] regular expressions?
[Link] i add elements to list , if it is defined as final
ex:final List<String> list= new ArrayList<>();?
[Link] you pass duplicate key to map what will happen?
[Link] b/w abstract class and interface?
[Link] b/w comparator and comparable?
[Link] to compare two database tables(clue: comparator, compare(), you have to compare database
objects.)?
[Link] to set timeout for the browser?(clue: restful client api.)?
[Link] workflow you used in your project?
[Link] java? why not c & c++?
[Link] written test they are asking sorting programs(bubblesort,quicksort,...)?
[Link] is time complexity? if you are going to implement sorting by your own which sorting you prefer?
and why?
[Link] is the use of volatile and synchronized?
[Link] is serialization? have you implement serialization in your project?
[Link] on io streams?
[Link] we are using @qualifier?
[Link] b/w BeanFactory and ApplicationContext?
[Link] about ioc container?
[Link] on string manipulations?(they are expecting solv by using regular expressions).
[Link] you are implemented polymorphism in your project?
[Link] you iterate map having key and list<values>?
[Link] b/w Iterator and ListIterator and Enumarator?
[Link] are all the collections are supporting ListIterator?
[Link] to make non-synchronized map and list as synchronized(by using collection method)?
[Link] is diff b/w collection and collections?
[Link] the junit test case for the below senario..
-->read array of elements into list<>.
[Link] are all the modifiers we can use inside method?(ans: only final)
[Link] is diff b/w spring-jdbc and hibernate?
[Link] are all the drawbacks of jdbc over hibernate?
[Link] are all the problems with inheritance?
[Link] is the use of hinernate session?
[Link] given one query in sql and they are asking corresponding criteria api query?
[Link] we are using @transient in hibernate?
[Link] are all the inputs we are giving to SessionFactory?
[Link] we are writing in hibernate-mapping file?
[Link] we are writing in hibernate-configuration file?
[Link]: in jsp page with 2 buttons, one for addbook and another is for showListOfBooks(by using spring
and hibernate)?
[Link] is use of @ComponentScan?
[Link] is use of dispather servlet?
[Link] are all the pre-processings tasks done by DispatcherServlet?
[Link] to render excel and pdf view to the enduser(using poi and itext api's)?
[Link] to validate valid username and password in spring?for validating can i directly interact with dao
without service?
[Link] defalut servlet container will handle multi-threaded applications , then why you are implementing
multi-threading in your application?

Java 8 with lambdas and streams


=============================
1. What is lambda expression?
[Link] Syntax.
[Link] fits with java ?
[Link] lambda ?
[Link] of lambda with Sample programs.
[Link] References.
[Link] as Argument
[Link] as Target
6.3. Limiaions
[Link] Composition.
[Link]:
9. Funcions belong o Sreams
9.1 Filter()
9.2 Map()
9.3Reduce()
9.4 groupingBy()
[Link] programs
[Link] is lambda expression ?
Ans: It is an anonymous function with out having name and return type.
we have done several times the below programming for multithreading purpose
with anonymous inner class.
import [Link].*;
class Test {
public static void main(String[] args) {
Thread th=new Thread(){
public void run()
{
[Link]("Heloo child thread");
}
};
[Link]();
[Link]("Heloo main thread");
}
}

Here the main thing is that to run that piece of code of run(),
so we can re write the code with it in lambda expression.
Generally a function have 4 things
[Link]
[Link]
[Link]
[Link] ype
Among them parameter and body are most important, so as
lambda expressions are anonymous function it has only body
and parameter ,
So let us see the above code with lambda expression.
2.
class Test {
public static void main(String[] args) {
Thread th=new Thread()->[Link]("Heloo child thread"); // left side of the symbol " -> "
parameter
//and right side is body
[Link]();
[Link]("Heloo main thread");
}
}
3. How lambda fits with java.
Java provides backward compatibility and making the lambda to use with
old codes and also new codes, that means you can happily use lambdas with
old API and also in the new API. As you can see the above threading model
which was an old code but fits with lambda,
Lambdas are backed by Intreface having single abstract method, which is knowas
funcional interface, e.g: Runnable, Callable..
we can use lambda in place of anonymous classes,
So to use lambda extremely devlopers making the api with interface having single abstract method.
4. Why Lambda ?
Here i have highlighted the only onemain point,
When ever we are programming with anonymous inner classes , so it creates one extra anonymous .class
file so for every anonymous class one extra . class file created , so javm loads time to load those classes
and
also create more garbage, so that garbage collector also running on background, which leads to
performance issue,
But in lamda expression no .class file is created like anonymous inner class, so this is simple and
performance is more.
[Link] of Lambda:
Let us take a simple iteration
import [Link].*;
import [Link];
public class Sample {
public static void main(String[] args) {
List<Integer> numbers = [Link](1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
//external iterators
// for(int i = 0; i < [Link](); i++) {
// [Link]([Link](i));
// }
// This is the traditonal way to iterate, there are so burden
// to initialize the starting value and setup the boundery conditiion etc..
//external iterators also
// for(int e : numbers) {
// [Link](e);
// }
// To reduce the burden, in java 5 for each loop is there ,but still ugly for
// is there .
//internal iterators
// [Link](new Consumer<Integer>() {
// public void accept(Integer value) {
// [Link](value);
// }
// });
// So in java 8 Consumer interface is there in [Link] pkg,
// and applying the anonymous class concept we can iterate as shown in above.
// [Link]((Integer value) -> [Link](value)); /
//[Link]((value) -> [Link](value));
// As we can implement lambdas for anonymous inner classes
// So the implemention is as above.
//Java 8 has type inference, finally, hold your tweets, but only for
//lambda expressions.
//[Link](value -> [Link](value));
//parenthesis is optional, but only for one parameter lambdas.
[Link]([Link]::println); // using method reference
}
}
So 4 to 5 lines of code can be replaced with one simple line i.e
[Link]([Link]::println);
So these are only basics of lambda, but real fun is there with Stream.
with lambda and stream the collection programming become easier.
various methods are there in Stream interface of [Link] pkg
which makes the collection claases easier to manipulate data.
6. Method reference:
This is used only , when we receive a parameter and we do not alter
it any way,but pass through it at that time.
Parameter as argument:
-----------------------------------------
[Link](e->[Link](e));
here parameter e is used as argument in [Link]()
So the above can be written as
[Link]([Link]::println);
Parameter as target
---------------------------------
[Link]()
.map(e->toString()) //(maping in to an expression)
.forEach(System::[Link]);
we can not use method reference if any manupulation on data.
[Link] composition
import [Link].*;
import [Link];
public class Sample {
public static void main(String[] args) {
List<Integer> numbers = [Link](1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
//given the values, double the even numbers and total.
int result = 0;
for(int e : numbers) {
if(e % 2 == 0) {
result += e * 2;
}
}
[Link](result);
[Link](
[Link]() // this is called function composition
.filter(e -> e % 2 == 0)
.mapToInt(e -> e * 2)
.sum());
}
}
Stream() produce a stream of given collection.
filter method filters the in put ,map method maps to an expression,

My Interview experience with greeet technologies.


[Link] a algorithm for finding the maximum of 3 numbers
[Link] a algorithm for finding simple interest.
[Link] a algorithm for finding the factorial of a number.
[Link] structures in C.
[Link] between procedures and functions in C.
[Link] all the concepts in object oriented programming language
[Link] are the benefits of XML?
8. Difference between XML and HTML?
[Link] between procedural and non-procedural language?
[Link] is DBMS?What is RDBMS?Explain the hierarchy in RDBMS?
11. What is SDLC?Explain the phases in SDLC?
[Link] Modifiers
[Link] try, catch,finally
[Link] logical programs.
[Link] Synchronization.
[Link] static and non static blocks.
[Link] codes and Type1,Type2,Type3,Type4,
[Link] between simple and prepared statement.
[Link] is ODBC? Explain about ODBC?
Basant Kumar Hota
July 15
Popular interview programme question
How to find middle element from collection?
Solution :-
===========
import [Link].*;
class FindMiddleElement
{
public static void search(List<Integer> list)
{
int middleNo1=0;
int middleNo2=0;
if ([Link]() % 2 == 0)
{
middleNo1 = [Link]([Link]() / 2);
middleNo2 = [Link](([Link]() / 2) - 1);
[Link]("Middle no is :" + middleNo1 + " " + middleNo2);
}
else
{
[Link]("Middle no is :" + [Link](([Link]() / 2)));
}
}
public static void main(String[] args)
{
List<Integer> list=new LinkedList<>();
for (int i=1;i <= 9;i++)
{
[Link](i);
}
[Link](list);
search(list);
}
}

[Link] is the method present in Iterator?


2 . what are the return type of hasNext () nd next(); why?
.hasnext(),next(),remove, [Link] for hasnext(),object for next-------------------------- hasnext() provides boolean coz it returns
wheather the next element is available or not, next returns the object we want to retrive from the list one by one

How can we create a thread without extends from Thread or without implements from Runnable or Callable
interface ?
Solution :-
Create an anonymous thread like below
class AnonymousThread
{
public static void main(String[] args)
{
new Thread(){
public void run()
{
for (int i=0;i <= 20;i++)
{
[Link](i);
}
}
}.start();
for (int i=65;i <= 80;i++)
{
[Link]((char)i);
}
}
}

Sometimes interviewer ask to create own immutable class without using final keyword?
Solution:-
=======
class MyImmutable{
private int i;
public MyImmutable(int i)
{
this.i = i;
}
public MyImmutable modify(int i){
if(this.i==i){
return this;
}else{
return new MyImmutable(i);
}
}
public static void main(String[] args){
MyImmutable m1=new MyImmutable(10);
MyImmutable m2=[Link](20);
MyImmutable m3=[Link](10);
[Link]([Link]()+" "+[Link]()+" :"+(m1==m2));
[Link]([Link]()+" "+[Link]()+" :"+(m1==m3));
}
}

Why we can't instantiate interface and abstract class ?


Ans :-
Ex:-
Interface A {
public void m1 ();
}
abstract class B {
public void m2 ();
}
👉See as per java documentation we can only define abstract method inside interface. Nd in abstract class
we can take both ok but my method have only header part not body r8
👉Think if compiler allow us to instantiate interface or abstract class then .then we can call method but that
method doesn't have any logic at the time of execution of method jvm will be impact and performance
issues will be come
👉One more things when we call method it will allocate memory in java stack area and it will create one
stack frame inside jsa. And that stack frame never destroy coz it doesn't have logic so there may be a
chance we will get StackoverflowError..
👉So Based on above reason sun people design in such a way that's why compiler restrict us to instantiate
interface and abstract class
I hope it will elpful fr u guyzs.

Medtronics Interview Question :-


===================
ONLY ONE TECHNICAL ROUND
1 . Project Description ?
2 . which Persistence layer r u using and why ?
3 . which server r u using in ur project and why?
4 . what is the difference between hibernate and Jdbc where we have to choose which one ?
5 . What is Lambda Expression ?
[Link] u use Aop in your project, Where ?
7 . Did u use transaction in ur project where?
8 . They give one senario then ask me to write the Queery for fetching 2 data but twist is there that only 1
column name is known by u

Hcl interview question


##Wap I have One Employee class with property empId,empName,emplSal,empDept first i have to sort by
empSalary if both employee have same salary then sort them by name ..try it time duration max (10 min)

May 8
Today's CTS interview question
Technical Round:-
=============
*Core-java
************
1 .Tell me the internal flow of Set implementation class with one example
2 . In HashMap if hashing collision occure then how to resolve it.
3 . can we add duplicate in set and map if yes why write one code
4 . Read data from file find the duplicate word and count them and sort them in desending order
5 . where to use Comparable and where to use Comparator did you ever used in ur project
6 . what is bubble sort can you write one programme. .?
7 . can I write try block single means without using try-catch or try-finally
8 . what is Executor framework
9 . how many way we can create thread and which one best approach and why
10 . jdk version u r using in ur project and why (be care on that question coz they indirectly ask u the
advantages of version or latest features added in New version )
*Jdbc:-
**********
1 . difference between Statement and PreparedStatement
[Link] give one db schema and ask me to retrieve data from DB by passing id
*Jsp:-
*********
[Link] cycle
2. list down the implicitly object
[Link] is the use of c tag library
*Spring :-
**********
[Link] is RowMapper when we have to use it write sample code not completely just give sm hints with
flow
[Link] is ResultSet Extractor where exactly we have to use
[Link] in my Spring bean configuration file I configure same bean with same id 2 times then what is the
problem and how to resolve it (contender)
4 . Spring Mvc Flow as per your Project
[Link] transaction, why nd how to work on it
6. How u handle Exception in ur Project just give some brief idea on it with annotation
*Webservices :-
**************
1 . WSDL ,what are the elements and just explain the role of each section verbally
[Link] is Rest,
3 . difference between Soap and Rest
[Link] one Resource method using Http method Post
[Link] Response u provide to presentation layer and how to bind Json Response
[Link] between @QuerryParm and @PathPatm which one best and where to use. ..
HR Round:-
=======
[Link] me about u. .not professional details just tell me personal details
[Link] me about ur payroll company
[Link] CTC
[Link] that much any reason
5 . Notice Period, is it negotiable?

[Link] --- i have 8lt ,5lt nd 3lt jar ...but i have all total 8 lt water then tell me how to manage 4lt nd 4lt in
first 2 jar ..u can use 3lt jar for measure and balancing
6.i have 9 ball and 1 ball is more weight and i have one measurement device/Weight balancer machine
how can u find out heavy weight ball tell me within 2 step

HCL INTERVIEW QUESTION:


========================
Core-Java----1 st round
===================
[Link] & abstract class
[Link] can u achive Abstraction With Real Time Example(Project)
[Link] your Project Where u are using oops concept..
[Link] u are using in ur project in which layer.
[Link] override all the method from super which keyword we have to [Link] why
[Link] abstract class achive less abstraction why not interface.
[Link] 5 classes which u r develope in your project with fully qualified name
[Link] are the exception u face in ur project development and how u resolve them explain
[Link] u are using Spring-jdbc why not hibernate
[Link] security u are using..
[Link] of log(Which one u use in your project)
Second-Round(CoreJava+Spring)
===========================
[Link] is abstraction
[Link] to create own immutable class write code
[Link] is singletone ,In your project did u use singletone ,Where write code
[Link] List allow duplicate why not Set with internal
[Link] is Dependency Injection
[Link] type of Injection u are using in ur project and why..
[Link] is autoware,Type explain with sample code
[Link] version Spring u used..
[Link] are the annotation u are using in ur project
[Link] Spring-transaction configuration
[Link]-Transaction annotation details with attribute why
12.@Qualifier annotation use with example
13.@RequestParm and @ModelAttribute where we have to use..
[Link] is ur daily activity in ur working environment
Project Description Asked in both round
Hr round:
========
[Link] company location ?
[Link] block
[Link] me ur employee-Idcard
[Link] u forget to take then call any one who will send it to u r8 now
[Link] u agree to submit 1 yr form 16
[Link] u agree to submit 2yr bank statement
[Link] ctc
8.(If more than 30% hike u want why ...)

What is [Link]() ?..


Shortly. ...
👉System:- system is a class which present inside [Link] pkg
👉Out:- out is a static variable present in System class of type PrintStream
✔Ex:-
class System {
private static PrintStream out;
}
👉println():-println() is a method which is present in side PrintStream class
✔Ex:-
class PrintStream{
Void print(){}
void println(){}

1)In arraylist we can add duplicate elements rite..now if i want to remove the duplicate elements how can
we remove
2)In string there are repeated characters there if i want to know how many times its repated how can we
get it..condtion is we shouldnt use any loops

import [Link];
import [Link];
import [Link];
public class RemoveDuplicates {

public static void main(String[] args) {

/* Creating ArrayList of Strings and adding


* elements to it
*/
List<String> al = new ArrayList<String>();
[Link]("Ajay");
[Link]("Becky");
[Link]("Chaitanya");
[Link]("Ajay");
[Link]("Rock");
[Link]("Becky");

// Displaying ArrayList elements


[Link]("Before:");
[Link]("ArrayList contains: "+al);

// Creating LinkedHashSet
LinkedHashSet<String> lhs = new LinkedHashSet<String>();

/* Adding ArrayList elements to the LinkedHashSet


* in order to remove the duplicate elements and
* to preserve the insertion order.
*/
[Link](al);

// Removing ArrayList elements


[Link]();

// Adding LinkedHashSet elements to the ArrayList


[Link](lhs);

// Displaying ArrayList elements


[Link]("After:");
[Link]("ArrayList contains: "+al);
}
}

1. Diff between spring singleton bean and user defined singleton class.
2. Diff between application context and webcontext.
3. Flow of spring mvc, what is the use of @requestmapping
4. How hibernate interact with application.
5. Diff between enumeration and iteration.
6. Why u use spring transaction?
7. If we create a static method m1, and nonstatic method m2 both are synchronized, in main
method we have 4 thread all are calling m1 and m2, is there any chance one method deadlock the
other. if not then why.
8. diff between error and exception. if checked exception is recoverable exception then how we can
recover it?
9. flow of spring mvc.
2. Tech Mahindra interview question
1. How to create a singleton class ?
2. How to create our own custom Exception ?
3. How to create our own immutable class.?
4. What is autoboxing and unboxing?
5. Why we use generic in collection?
6. What is the difference b/w HashMap and HashSet?
7. Which set insert element in insertion order.?
8. What are the implict object in jsp?
9. In which jsp class all implict objects are available?
10. In ur project which spring annotation are u used?
11. Why hibernate u used in ur project.?
12. Explain ur role in ur project ?

[Link] real time use case of serialization except webservices?


2.I have 100 independent pojo(Entity) classes in hibernate..How many mapping files we should create?
(Ans:It is not recommended to create 100 mapping files..we can use annotations)except this [Link] u
know any alternatives..plz answer me..
Answers:
[Link] time use case of serialization is when we are persist data in our database the pojo data will transfer over the network
to db so that's why it's recommended to implement ur model class from serializable interface.

2. You could repeat <class> tag as many times as you want in hibernate mapping files .
e.g.
<hibernate-mapping>
<class name="Employee" table="employee">
<id name="id" type="[Link]">
<column name="id"/>
<generator class="native"/>
</id>
<property name="name" type="[Link]">
<column name="name"/>
</property>
</class>

<class name="Address" table="address">


<id name="id" type="[Link]">
<column name="id"/>
<generator class="native"/>
</id>
<property name="address" type="[Link]">
<column name="address"></column>
</property>
</class>
</hibernate-mapping>
=> In case you don't want large xml(mapping) files,you can avail "import" facilities in configuration file
<mapping resource="[Link]"/>
<mapping resource="[Link]"/>

Write a program to reverse a string by word without using any predefined method.
b) WAP to find mirror of a given matrix. (Explanation: you have to input a square matrix and find its mirror
matrix i.e. left mirror and right mirror.)
c) WAP to find occurrence of particular letter in a string and also find how much time it is occurrence.
d) What is inheritance? Take a real world scenario and explain. Also why it is important in programming
world?
e) Tell me what you understand by polymorphism and abstraction?
f) What is this keyword and what is its use in java? What is the problem which we face when we do not use
this in our program?
g) What is checked and unchecked exception? How will you create your own exception?
h) Why we are using finally block? Tell me a use case of this.
i) Why strings are immutable?
j) What is difference between list and set? Tell me some classes which are implementing these interfaces.
k) What is servlet? What is difference between GenericServlet and HttpServlet? If GenericServlet is there
then what is use of HttpServlet?
l) What is join? Tell me its type.
m) What is normalization?
n) They give me a table and said that find second highest salary of employ from the table.
o) Explain your project. (some cross questions were asked while I was explaining the project)
(Some more questions are from database but I forget…For technical interview follow HARI sir book and
read each line and do all exercise…and never miss the class. This would be sufficient for easily cracking
the interview)
Third and last round:
---------------------------
Followings are questions:
a) Tell me about yourself.
b) What is your goal after 5 years?
c) What is difference between hard work and smart work?
d) Why should I hire you?

what r the roles and responsibilites thet ur palying in ur project ?


what kind of work ur looking for?
can u tell me what r the design patterns that u r used?
diff between factory design pattern and abstract factory design pattern

how do u ref an element inside ur css by using byname and by type hoe do u do that wt u use

diff between equijoin and natural join

what is cross join

what is the difference between leftouter join and right outerjoin:

what is default join ?

what is the use autowireing?

i have a table it have some coloumns i want to swap contents of these two coloumns how will i do that

if i am not intersted to writeing the java program i want to do with query how can i?

can u tell me mutable and non mutable types?

what r the best practices of garbage handling?

how do u resolve null pointer exception?

JSE
- What do you mean by polymorphism in java? Where did you use it in your experience?
- Can you explain me about Java OOPS?
- Why is abstraction in Java?
- What is encapsulated object?
- Why is java bean used for?
- When do you use an array?
- How many JVMs can we start in a single system?
- What are the new features in Java 7 and 8?
- How do you serialize an object and why?
- Why is the use of garbage collection in java? How does it work? Can we call it explicitly?
- What is the default size of a JVM? Can we increase the size of it? How?
- How do you handle exceptions? Can you explain me the flow of try-catch-finally? Where do you
commit/rollback the transactions?
- How many types of exceptions, are there and did you create any custom exceptions in your project?
- Have you used multi-threading in your project?
- How do you resolve ConcurrentModificationException? Why does it occur?
- When do you use ArrayList, LinkedList collection?
- When do we go for Map collections?
- When do you use Properties collection?
- How many ways, can we create a thread? When for what?
- Can we synchronize a block at object-level?
- Do you have any idea about String Constant Pool? Why is it?
- Why do we use for “forEach” loop?
- What is a singleton class? Why do we create it? Did you create any singleton classes in your project?
What components, did you make singletons?
JEE
- Can you explain the servlet request flow?
- Is servlet a singleton object? If yes, why is it singleton? Can we make it prototype? If yes, how can we
make?
- Can you explain the request flow for the JSP page in server? Where do you place JSP pages in your
project?
- Can we forward a request to a JSP page if it exists in WEB-INF?
- Can we develop web application without [Link]? If yes, how can we?
- What annotations, do you aware of java? What is for what purpose?
- If we want to do some common work for all the components in the application. Where can we do that
and how?
- If we want to load fixed data before first request into the JVM. Where can we write that logic so that it is
loaded before any request to the application?
- Can we replace servlet with JSP? What are the advantages and disadvantages?
- Can we replace JSP with servlet? What are the advantages and disadvantages?
- Is JSP a singleton object in JVM?
- What is the purpose of session object?
- Why application server? Why not webserver?
Spring
- Why IOC? How does it work?
- How can we make bean as singleton and prototype?
- How many scopes, are there in spring? What for what purpose?
- Why did you use spring?
- How do you make class a bean in IOC using annotations?
- What MVC annotations, are you aware of? What for what purpose?
- When do you use @Autowired?
- Did you use AOP? If yes, why is it used for?
- Did you use Spring Jdbc? If yes, why not Java Jdbc and Hibernate?
- What is the use of RowMapper in Spring Jdbc?
- How to use Spring with Hibernate?
- When to go for setter injection over constructor injection?
- How do solve constructor injection confusion?
- What is an aspect in AOP?
- How many advices, are there in Spring AOP? What are those?
- How do you specify a name to a bean in IOC using annotations?
- Did you use java configuration class? If yes, why did you use it? What annotations, did you use on java
configuration class?
- Can we have multiple java configuration classes? If yes, how can we achieve? When should we do that?
- What is the purpose of DispatcherServlet? How can you provide configuration xml file to it?
- Can you develop a spring application by only using annotations including [Link]?
- Did you work on transactions in your project? Why did you use? Where did you use?
- How many transactions, are created for a request? Why?
- Why spring annotations? Why not xml?
- Can you explain your project request flow?
Hibernate
- What does load() method do? What does get() method do?
- Can you make get() method as lazy loader? If yes, how?
- How do mention an attribute as a primary key or composite primary key?
- Is caching available in Hibernate? How many caching levels available in Hibernate? What for what
purpose?
- Did you work on HQL? If yes, why did you use? How do you execute HQL?
- Do you have idea on Criteria in Hibernate? If yes, what is it? Why is it used over HQL?
- What annotations, did you use in your project? What for what purpose?
- Can you write one-to-many relationship xml configuration with an example?
- Do you remember normalizations? Can you explain 2nd normalization?
- Why do we normalize data?
- Did you use Increment ID Generator? How does it work?
- Why not Sequence ID Generator?
- Why Hibernate? Why not Java Jdbc?
- What is the parent exception in Hibernate? What type of exception is it and why?
- How many session objects, do you create for a request?
- Can you tell me the differences between save() and saveOrUpdate()? How does saveOrUpdate() work?
- Can you tell me the differences between update() and merge()?
- Can you write a snippet of code for creating SessionFactory? Where and when do you create
SessionFactory? How many SesionFactory objects, do you have in your project? Why?
Web Services (SOAP)
- How many sections, are there in a SOAP xml? Can you explain their purposes?
- Why SOAP? Why not REST?
- What is the differences between JAXRPC and JAXWS?
- What implementation, did you use in your project? Why?
- How do you secure a Web Service?
- What do you mean by a Web Service?
- Can we send JSON or HTML over SOAP Web Services? If no, why can’t we?
- Assume, there are two systems A and B. A is consuming B’s service. One day, we got to change the
signature of the method in Web Service class by adding new parameter. What changes, might be occurred
in A’s and B’s systems?
- Are you a consumer or producer of Web Service? If both, explain?
- How many Web Services, are you aware of? Explain their advantages/disadvantages?
- How do you share your Web Service to your consumers?
- Can you explain me the use of WSDL in a Web Service? What sections, does it contain and their
purposes?
- How do you make class a Web Service in JAXWS?
- What annotations, are you aware of in JAXWS? What is for what purpose?
XML Technologies
- What is purpose of XML? When do we use XML? What is well-formed XML? How do you validate an
XML?
- What is an XSD?
- How do you convert XML to an object?
- What is SAX/DOM mechanism? Which is good in performance?
RESTful Services
- Why REST? Why not SOAP?
- Can we send HTML code over REST? How?
- What annotations, are you aware of in REST? What is for what purpose?
- What do you mean by resource in REST? How do you make a resource in REST?
- How many places, do you get data from http request?
- What is the purpose of @PathParam?
- What is the purpose of @MatrixParam?
- How do you handle exceptions in REST?
- What are http response codes and their purposes?
- How do share your REST Service info to consumers?
- How do you consume RESTful Service? Can you write a snippet of code?
- Can you explain me GET, POST, PUT methods of HTTP?
- What is a sub-resource?

*I was asked 3-4 questions on every technology/tool highlighted/mentioned in my resume.

*I suggest you to learn by understanding the topic/technology, not by questions.

*I remind everyone to follow this listen-understand-practice-explore.

How you distributed your provider to consumer?


What are the challenges that u are faced while working with provider?

15-02-17(Infinite Computer Solutions India Ltd.)


Prog-
1-Write a program to revrse a string without using StringAPI.
2-Change Order of vowels in the string;(eg-"you are cool boy"="yuo era cool boy")
3-Find Missing alfabates in the string.(eg-qwer tyu op asdf gh jl xcv nm ,missing
are =ikzb)

technical interview qsn-


1-Different Between Hashmap And Concurrent Hashmap?
2-whats are the enhancements in multithreading in 1.7v of java?
3-what is lambda expression in java?
4-What is Deadlock?
5-What is work of fork/join class in java?
6-What is "WITH" clause in SQL?
7-Spring IOC container?
8-Bean scopes?
9-what are the interfaces spring impliments?
10-difference between @path & URL?
11-Design Pattern catagories ?
12-what is Factory & Singleton Design Pattern& in which catagory they fallunder?
13-How to create Factory object in hibernate?

1. By make our class as immutable what we achieve. In your project where u use.

2. In your project where u use interface and abstract class.


3. Did you ever face ConcurrentModificationException, when it will occur.

4. Diff between spring singleton and user defined singleton.


5. Flow of spring mvc, what is the use of @requestmapping.
6. Diff between enumeration and iteration

7. If we create a static method m1, and nonstatic method m2 both are synchronised, in main method we
have 4 thread all are calling m1 and m2, is there any chance of interruption, if not then why

8. diff between error and exception. if checked exception is recoverable exception then how we can recover
it?

9. [10,5,19,11,20,8,13]. Find the second smallest and second highest from the array.
10. If we have same url in two controller. For example @RequestMapping(value="/add") then what wil

[Link] SOAP based Web Services Architecture how it internally works.


[Link] Architecture Rest based Web Services
[Link] we are developing Consumer in SOAP after getting WSDL uri how you will generate binding
classes without using Any 3rd party vendor provided tools.
[Link] you handle Exception in SOAP Based Web Services .
5.I configured MEF as XML if i will pass JSON then what will be happen ? and how u will test it .
[Link] are the HTTP methods provided by JAX-RS ?
[Link] is HLTC ?
[Link] is Service Locator Design Pattern
[Link] is Singleton and what is the use to Make a class as Singleton
10.I Configure my DB and performing some business operation but i am getting OutOfMemoryError
that's why my server was crashed how to resolve this issue.
[Link] you used HTTPClient to develop Consumer in SOAP Based Web Services

Program:-

Copy one text file data into another text file


Difference between include directive and include action?
Reflections?
If I send json to resource I need to convert into object?---content handlers
Spring jdbc:-
Query for object ,query for list,row mapper

How to make hash map threadsafe? [Link]();

Difference between filter and hadlerinterceptor?


if our request is not valid also filter will process it but in spring if use handler interceptor then request is
recived to dispatcher servlet to get the controller dispatcher servlet will send the request to handler mapping
in handler mapping it check request is valid or not if valid then along the controller it give the interceptor the
dispatcher servlet then disaptcher servlet will call the interceptor and interceptor chainging

What is static pointcut and dynamic pointcut ..what is diff between static and dynamic pointcut?
Static point cut:

--> The proxy for target class will be created at runtime.


--> But here the proxy will be created with the methods those supplied by taking the help of static pointcut class.
--> Due to above one performance will be optimized

Dynamic point cut :

--> The proxy for target class will be created at runtime.


--> But here the proxy will be created for all the methods of the target class.
--> Here when we want to even consider arguments values also for conditional checking then we need to go for
dynamic pointcut.

You might also like