Interview Questions: Core Java
Interview Questions: Core Java
Core Java
1 Difference between Interface and Abstraction , where have you used in you project, Give real time
senerio for this. Which one you will prefer and why? (3)
2 What is serialVersionUID
3 Is Resultset interface ? who implements it (2)
4 What is Reflection
5 How do you make two classes loosely coupled in core java (Without using spring)
6 What is synchronization? Where did you used serialization in you project (3)
7 Write synchronized method
8 Explain internal working of Hashmap (3)
9 Do hashmap allows duplicates keys or not
10 Class A extends B,C - > is it possible in Java
11 ArrayList<String> list = new ArrayList<String>;
list.add(“str”);
list.add(10);
will it compile successfully or not?
12 What is method overloading and method overriding (2)
13 Why Java does not support multiple inheritance (3)
14 What is hashcode method and why do you override hashcode and equals method (4)
15 Can we have two objects with same hashcode
16 What are the features of the Java
17 What is the diff between static block and static keyword
18 When do you go for abstract class and when do you go for interface
19 Write your own immutable class (4)
20 Write final class
21 Difference between hashmap and linkedhashmap (3)
22 Explain OOPS concepts (Asked to write on White Board)
23 What is concurrent Hashmap (2)
24 What is auto boxing and unboxing
25 What are the wrapper classes in Java
26 How memory will be allocated for String
27 What is the diff between List and Vector (2)
28 What is treeMap and internal working of the same
29 What is the diff between Comparable and Comparator (4)
30 Sort Employee Objects based on Salary using treeMap
31 Write your Own Exception Class (2)
32 What is Garbage Collection
33 Java 5 , 6,7, 8 Features
34 What is the use of Lambda Expressions
35 How do you implement static in your project
36 How do you implement synchronization in your project
37 Can you create object for interface
38 what is war,ear,rar?
39 Difference between hashmap vs concurrenthashmap? (2)
40 How to remove duplicates in arraylist?
41 Difference between arraylist vs linkedlist? (2)
42 try{
..........
}
catch(ArithmeticException e){
...
}
catch(Exception e){
....
}
catch(FileNotFound e){
...
}
is correct or not?
43 Difference between encapsulation and abstraction? (3)
44 What are Java 1.7 Features
45 How to implement custom hashmap?
46 How to handle exceptions in java 1.7 using multiple catch blocks? (2)
47 Real time scenario in using Arraylist. Write the code
48 JDK 1.5 features
49 JDK 1.7 try with resources feature
50 why HashTable not allow null?
51 what happen if we trying to add duplicate key in HashMap ?
52 how to read data from file and store it in another file.
53 I have one interface we have 3 methods, but i want to implement one method?
54 how to achieve abstraction
55 can I able to create 1000 objects for singleton ? if yes/no how/reason ?
56 throws and throw usage in project?
57 comparable and comparator implementation and internal mechanism? (2)
58 try with finally is possible ?
59 return 1 in catch and return 0 in finally what will be the output ?
60 return 2 in try , return 1 in catch and return 0 in finally what will be the output ?
61 which one will take more memory int or Integer and why ?
62 what is copyOnWriteArrayList ?
63 How to deal with out of memory error?
64 Apart from collections what is the use of hashcode and equals method ?
65 Difference between primitive and wrapper types ?
66 What is string builder, where you used in your project ?
67 Difference between String,StringBuffer and StringBuilder ? (2)
68 write program for How to access static and non-static variable from another class ?
69 Explain about OOPs concepts ?
70 Are you used multithreading and where ?
71 I am having map1 and map2, how to combine two maps in single map ?
72 final vs finally ? system.exit() in finally what will happen ?
73 given string is palindrome or not ?
74 Explain about System.out.println ?
75 How to concat String and how to append string buffer
76 Where did you used static and dynamic polymorphism
77 How JVM works internally
78 Can I implement abstraction in POJO or Model class
79 Diff between finally , finalize, final
80 What are exception, checked , un checked exception
81 Scenario based questions on exception
Try{
Try{
}
}catch(Exception e)
Is it valid?
82 Diff between hashmap and hashtble
83 Why immutable concept in java
84 You have list of 10 object in list. Check these objects exist in DB or not
85 Diff between array and arraylist
86 What is constructor , can we have private constructor, can you access outside of a class
87 If all the methods is abstract in abstract class then why we need interface
88 Shallow Cloning and deep Cloning
89 How to find method is synchronized or not
90 DOM parser vs SAX parser
91 List<String> lst= new ArrayList<String>();
Jsp/Servlets/Script (J2EE)
1 Diff between jsp include action tag and include directive and Purpose (2)
2 What is AJAX
3 How do create deadlock in servlet class
4 How do you get count of how many times servlet is accessed
5 How do you ensure the session is closed when browser is closed without logging out
6 Explain servlet life cycle (5)
7 What is session and When is the session id created
8 Can we call destroy method inside the init method and what will happen
9 Diff between page and pagecontext
10 Diff between http servlet and generic servlet. Which one have you used in your project and why
11 What are the JSP implicit objects (4)
12 Given a user form , how to pass from front end to back end in your project
13 What are the servlet scopes
14 Given one textbox in JSP , how do you save data in DB, The flow from front end to backend
15 What are the JSP tags used
16 What is JSTL , can you write custom tag library
17 How to invalidate the session
18 How to get the session object
19 How to get the request dispatcher
20 What is Servlet Collaboration
21 Tell me something about cookies
23 Diff between ServletContext and PageContext
24 Write ajax call syntax
25 How to get the text box value in jquery
26 Difference between web server vs application server?
27 For example in servlet mapping file having multiple mappings with same which one is taken
<servlet-mapping>
<servlet-name>sample</servlet-name>
<url-pattern>/sam</url-pattern>
<url-pattern>/sam</url-pattern>
<url-pattern>/sam</url-pattern>
</servlet-mapping>
28 Why we need filters in servlet? (2)
29 Who is responsible for servlet initialization?
30 JSP custom tags(JSTL)
31 JSP directives
32 How do you declare variables in JSP?
33 How to comment code in jsp and html?
34 How to convert jsp to Servlet ?
35 Three fields having same ID,but i want all three field values, How to get ?
36 How SinglePageApplication(SPA) will work ?
37 Three fields having same ID, If iam getting value using ID what will happen ?
38 how to get values from Jquery and javaScript ?
39 What are the javascripts validation done in your project (2)
40 Diff between Servlet and filter ?
41 Servlet is multi-threaded or not
42 How JSP converted to HMTL internally
43 What are the data type in json
44 How to navigate from one page to another
45 Difference between servlet Config and ServletContext?
46 Difference between forward() and sendRedirect()?
47 How we will handle the exceptions in servlet?
48 What is contextparam?How we can write Context params in web.xml?
49 How we can write the code Using ServletContext object?
50 Difference between Action Include() and Directive Include()?
51 What is Action elements in Jsp?How we can access applet to Jsp?
52 Implicit objects in Jsp?What is pagecontext?
Struts
1 How to do validation in Struts
2 New features in Struts 1.3
3 Struts flow
4 Types of Action in Struts
Spring
1 What are the bean scopes (5)
2 When do you use @Qualifier annotation (3)
3 Explain Spring MVC flow (4)
4 What is @RequestMapping and why it is used (1)
5 What is dependency Injection (3)
6 What is autowiring and how many types (4)
7 What are the annotations you have used
8 Explain DAO layer in Spring project
9 What is IOC (3)
10 What is the return type of requestMapping
11 Diff between setter and constructor injection (2)
12 What is AOP , jointpoint, pointcut, advise , aspect
13 Explain Spring transactions
14 What are the Spring 3 and Spring 4 Features
15 What is the diff between MVC 1 and MVC 2
16 what is the difference between httpsession and session in spring.
17 Spring Bean Life cycle (2)
18 From controller I am passing two parameters to backend, explain process of how will get
response ?
19 How to create Session ?
20 how to get session object in Spring Controller
21 difference between byType and ByName. (2)
22 How do you manage transaction and security in spring?
23 If PDF report not generating then how do you debug/analyze
24 Bean A contains B. Bean B contains A. Which bean will be initialized
25 What diff between request , prototype
Hibernate
1 Can we have two DB in single hibernate application and how do you configure it
2 What are the properties/tags in the hibernate configuration file
3 How did you used password in the configuration file
4 What is criteria , where have you used it (5)
5 What is projection , where have you used it (3)
6 Explain session factory , session and transaction (2)
7 Why do you need transaction in project
8 What are the drawbacks of the JDBC and why do you choose Hibernate
9 What are the hibernate object states
10 Diff between merge and update method
11 What is diff between get and load (2)
12 What is second level cache and how to enable it
13 How to print query on console in Hibernate
14 What are the mapping in hibernate and write onetomany
15 how to configure spring with hibernate
16 Why Hibernate ? why it came into picture if already we have JDBC
17 Hibernate second level cache? List out them
18 What is lazy initialization? what is the default and how to enable it?
19 Advantage of hibernate 4.0
20 What is difference between hibernate inverse and cascade
21 In which scenario Restrictions will you use
22 Diff between 1st level cache and 2nd level cache ?
23 Hibernate configuration (2)
24 JDBC what are the advantages of Hibernate over
Design Pattern
1 How do you write Singleton class , where have you used in you project (2)
2 What are the design patterns you know
3 What is Design Pattern
4 What is Façade Design Pattern
5 How DO you implement Factory Design pattern in your project
6 Explain Adapter pattern
7 Explain Strategy pattern
8 Difference between factory and command design pattern
9 singleton usage and purpose ?
10 how to make connection as singleton ?write code ?
11 Explain factory pattern and MVC
12 Why Design pattern is required ?
Web Services
1 Which protocol your service is using
2 What is WSDL full form and explain about it
3 How do you differentiate between web service un available and timeout
4 How soap services works
5 How to make synchronous and asynchronous call using web service
6 JMX purpose
7 SOAP and REST diff ?
8 Why SOAP used in your project?
9 How you know the request sent from consumer to provider application or not ?
10 what are the tools you used ?
11 data type of data(how it will be) in soap ws ?
12 how to check soap and rest services ?
13 What is resource
14 why we prefer SOAP over REST for Banking domain
15 Which method you can use in update operation in Rest?
16 Which method can we use Retrieval operation In rest?
17 How we can give the path using get operation in rest?
18 What is Jax-b? What is Jax-p?
Project / Process
1 Explain your project - Project flow - From requirement gathering to deployment (4)
2 Explain architectural flow
3 Technical flow and Functional flow of project (3)
4 Explain the technical flow of the latest project you have worked on. In depth explanation is
needed.
5 If you have crore of records which one do you prefer to use collections or DB and why?
6 Query using GroupBy clause.
7 How your application communicates with DB?
8 Which collection classes you have used in your application? When do you go for Hashmap and
when to prefer arraylist?
9 Technology Stack for your project ?
10 Handling deployment / Deployment plan
11 About scrum master ?
12 Difference between daily meetings and weekly meetings ?
13 What is SDLC(based on your project) ?
14 How you test your code? After your testing where you passed your code?
25 Suppose you can get the errors in WebSphere server how can you can resolve?
General /Others/Testing
1 What is the technical challenge faced in your project and how did you solve it (2)
2 what is Mockito in unit testing.
3 project scenario based procedure and function program ?
4 Asked to create a new layer in the existing flow for a new requirement
5 testing methods, what are the types of testing you did in your project before code moving ?
6 how you handle transaction related things ? about transaction management ?
7 How you maintain security in your project ?
8 How to protect password from exposing to developer and deployed
9 About your company ?
10 Banking Domain knowledge and SWIFT rules ?
Note :
• Please do mention where you have used the concept in your project
• Please have perfection in Interface and Abstract class with real time scnerio and which one you
will prefer and why?