0% found this document useful (0 votes)
44 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)
44 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)

1.how to put class in hash map?


2.custom exceptions?(how u will write)
3.XML(total details?)
4.how to iterate database values?
5. what is jndi and explain?
6.weblogic(how u will deploy application in weblogic?
Hiebrnate
1.hibernate interfaces?
2.hql queries?
3.how u will change oracle to mysql ?
4.hql to eliminate duplicate values?
spring
1. spring ioc?
2.autowiring? how u implementd?
3.setter and constructor injection ?what u implemented in u r project?
4.how to load optional beans?
5.scopes of beans?
General
1. static where u used in ur projects?
2.in hash map can u take key as object?
3.hash map(can hash map key allow duplicates)?
4.collections used in u r project?
5.what are the packages u used in ur projects?
6.hash set?
7.how u will eliminate duplicate values from a table?
8.prototype and singleton difference?
9.load on start up?
10.auto 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
30.Question:
publicclass A {
String name;
public A(String name) {
this.name = 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:
1.project architecture?
2.spring flow?
3.list out all the annotations in spring?
4.what are all the annotations you used in your project on restful services?
5.in hibernate use of cascade and inverse?
6.first level cache? second level cache in hibernate?
7.waht is diff b/w arraylist and linkedlist?
8.can you explain the internal flow of hashmap?
9.what is the diff b/w hashmap and hashtable?
10.diff b/w array and arraylist?
11.diff b/w arraylist and vector?
12.in your project where you used cuncurrent hashmap?
13.waht is java annoying?
14.diff b/w callable interface adn future interface in concurrent package?
15.class loaders?
16.how can you take list into map?
17.how can you take map into list?
18.when you will get ClassNotFoundException and NoClassDefFoundError?
19.how you implement exception handling in your project?
20.where you implement multi-threading in your project?
21.what are all the design patterens you oberved in spring?
22.which design patters you used in your project?
23.what are all the critial situations you come across in your project?
24.why wait() placed in object class ? why not it is placed in Thread class?
25.waht is use of intern() in spring?
26.what is diff b/w String str="xyz"; and String str2= new String("xyz");
27.expalin about java architectue?
28.explain about jvm architecture?
29.data 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?
31.how 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?
33.diff b/w rest and web(soap)?
34.agile methodolgy?
35.how to create web-services project and spring project using mavan?
36.what is diff b/w throw and throws?
37.can you tell me java8 features?
38.what are all the contents in wsdl?
39.refer regular expressions?
40.can i add elements to list , if it is defined as final
ex:final List<String> list= new ArrayList<>();?
41.if you pass duplicate key to map what will happen?
42.diff b/w abstract class and interface?
43.diff b/w comparator and comparable?
44.how to compare two database tables(clue: comparator, compare(), you have to compare database
objects.)?
45.how to set timeout for the browser?(clue: restful client api.)?
46.what workflow you used in your project?
47.why java? why not c & c++?
48.In written test they are asking sorting programs(bubblesort,quicksort,...)?
49.what is time complexity? if you are going to implement sorting by your own which sorting you prefer?
and why?
50.what is the use of volatile and synchronized?
51.what is serialization? have you implement serialization in your project?
52.programs on io streams?
53.why we are using @qualifier?
54.diff b/w BeanFactory and ApplicationContext?
55.explain about ioc container?
56.programs on string manipulations?(they are expecting solv by using regular expressions).
57.how you are implemented polymorphism in your project?
58.how you iterate map having key and list<values>?
59.diff b/w Iterator and ListIterator and Enumarator?
60.what are all the collections are supporting ListIterator?
61.how to make non-synchronized map and list as synchronized(by using collection method)?
62.what is diff b/w collection and collections?
63.write the junit test case for the below senario..
-->read array of elements into list<>.
64.what are all the modifiers we can use inside method?(ans: only final)
65.what is diff b/w spring-jdbc and hibernate?
66.what are all the drawbacks of jdbc over hibernate?
67.what are all the problems with inheritance?
68.what is the use of hinernate session?
69.they given one query in sql and they are asking corresponding criteria api query?
70.why we are using @transient in hibernate?
71.what are all the inputs we are giving to SessionFactory?
72.what we are writing in hibernate-mapping file?
73.what we are writing in hibernate-configuration file?
74.senario: in jsp page with 2 buttons, one for addbook and another is for showListOfBooks(by using spring
and hibernate)?
75.what is use of @ComponentScan?
76.what is use of dispather servlet?
77.what are all the pre-processings tasks done by DispatcherServlet?
78.how to render excel and pdf view to the enduser(using poi and itext api's)?
79.how to validate valid username and password in spring?for validating can i directly interact with dao
without service?
80.by 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?
2.Basics Syntax.
3.How fits with java ?
4.Why lambda ?
5.Simplicity of lambda with Sample programs.
6.Mehod References.
6.1.Parameter as Argument
6.2.Parameter as Target
6.3. Limiaions
7.Fncion Composition.
8.Sreams:
9. Funcions belong o Sreams
9.1 Filter()
9.2 Map()
9.3Reduce()
9.4 groupingBy()
10.Sample programs
1.What 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 java.util.*;
class Test {
public static void main(String[] args) {
Thread th=new Thread(){
public void run()
{
System.out.println("Heloo child thread");
}
};
th.start();
System.out.println("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
1.Nmae
2.parameter
3.Body
4.Return 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()->System.out.println("Heloo child thread"); // left side of the symbol " -> "
parameter
//and right side is body
th.start();
System.out.println("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.
5.Simplicity of Lambda:
Let us take a simple iteration
import java.util.*;
import java.util.function.Consumer;
public class Sample {
public static void main(String[] args) {
List<Integer> numbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
//external iterators
// for(int i = 0; i < numbers.size(); i++) {
// System.out.println(numbers.get(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) {
// System.out.println(e);
// }
// To reduce the burden, in java 5 for each loop is there ,but still ugly for
// is there .
//internal iterators
// numbers.forEach(new Consumer<Integer>() {
// public void accept(Integer value) {
// System.out.println(value);
// }
// });
// So in java 8 Consumer interface is there in java.lang.function pkg,
// and applying the anonymous class concept we can iterate as shown in above.
// numbers.forEach((Integer value) -> System.out.println(value)); /
//numbers.forEach((value) -> System.out.println(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.
//numbers.forEach(value -> System.out.println(value));
//parenthesis is optional, but only for one parameter lambdas.
numbers.forEach(System.out::println); // using method reference
}
}
So 4 to 5 lines of code can be replaced with one simple line i.e
numbers.forEach(System.out::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 java.util.stream 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:
-----------------------------------------
numbers.forEach(e->System.out.println(e));
here parameter e is used as argument in System.out.println()
So the above can be written as
numbers.forEach(System.out::println);
Parameter as target
---------------------------------
numbers.stream()
.map(e->toString()) //(maping in to an expression)
.forEach(System::out.println);
we can not use method reference if any manupulation on data.
7.Function composition
import java.util.*;
import java.util.function.Consumer;
public class Sample {
public static void main(String[] args) {
List<Integer> numbers = Arrays.asList(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;
}
}
System.out.println(result);
System.out.println(
numbers.stream() // 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.


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

1.What is the method present in Iterator?


2 . what are the return type of hasNext () nd next(); why?
.hasnext(),next(),remove, 2.boolean 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++)
{
System.out.println(i);
}
}
}.start();
for (int i=65;i <= 80;i++)
{
System.out.println((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=m1.modify(20);
MyImmutable m3=m1.modify(10);
System.out.println(m1.hashCode()+" "+m2.hashCode()+" :"+(m1==m2));
System.out.println(m1.hashCode()+" "+m3.hashCode()+" :"+(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 ?
6.Did 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
2.they give one db schema and ask me to retrieve data from DB by passing id
*Jsp:-
*********
1.Life cycle
2. list down the implicitly object
3.what is the use of c tag library
*Spring :-
**********
1.What is RowMapper when we have to use it write sample code not completely just give sm hints with
flow
2.what is ResultSet Extractor where exactly we have to use
3.if 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
5.Spring 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
2.what is Rest,
3 . difference between Soap and Rest
4.Write one Resource method using Http method Post
5.which Response u provide to presentation layer and how to bind Json Response
6.Difference between @QuerryParm and @PathPatm which one best and where to use. ..
HR Round:-
=======
1.Tell me about u. .not professional details just tell me personal details
2.tell me about ur payroll company
3.Expected CTC
4.Why that much any reason
5 . Notice Period, is it negotiable?

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

What is System.out.println() ?..


Shortly. ...
👉System:- system is a class which present inside java.lang 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 java.util.ArrayList;
import java.util.List;
import java.util.LinkedHashSet;
public class RemoveDuplicates {

public static void main(String[] args) {

/* Creating ArrayList of Strings and adding


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

// Displaying ArrayList elements


System.out.println("Before:");
System.out.println("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.
*/
lhs.addAll(al);

// Removing ArrayList elements


al.clear();

// Adding LinkedHashSet elements to the ArrayList


al.addAll(lhs);

// Displaying ArrayList elements


System.out.println("After:");
System.out.println("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 ?

1.One 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 answer.if u
know any alternatives..plz answer me..
Answers:
1.Real 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="java.lang.Integer">
<column name="id"/>
<generator class="native"/>
</id>
<property name="name" type="java.lang.String">
<column name="name"/>
</property>
</class>

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


<id name="id" type="java.lang.Integer">
<column name="id"/>
<generator class="native"/>
</id>
<property name="address" type="java.lang.String">
<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="Employee.hbm.xml"/>
<mapping resource="Address.hbm.xml"/>

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 web.xml? 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 web.xml?
- 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

1.Explain SOAP based Web Services Architecture how it internally works.


2.Explain Architecture Rest based Web Services
3.When we are developing Consumer in SOAP after getting WSDL uri how you will generate binding
classes without using Any 3rd party vendor provided tools.
4.How 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 .
6.What are the HTTP methods provided by JAX-RS ?
7.What is HLTC ?
8.What is Service Locator Design Pattern
9.What 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.
11.Did 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? Collections.synchronisedmap();

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