Skip to main content

Java Questions

Just a few interview questions which I faced in the interviews ... the thought of sharing..

 1) What is JVM?
2) What is JDK?
3) What is JRE? Differences between JDK and JRE?
4) How Java is platform independent?
5) When you say java FileName what happens? Every time it creates a new JVM instance or how?
6) What are the benefits/features of java?
7) What are the differences between C# and Java?
8) What are the major properties of java? i.e. Encapsulation, Inheritance, Abstraction and polymorphism. Explain those and give some examples of them.
9) What is the difference between interface and abstract class? Examples of each and when to use what?
10) How the string is immutable? What is immutable? Any other classes in java are immutable?
11) How you can create an immutable class? What happens internally?
12) What are the differences between final, finally and finalize?
13) What are differences between string buffer and string builder and when to use what?
14) Various questions on access modifiers like public, protected, private and default.
15) Various questions on static keyword, can static methods are called by instance variables. What is the use of static? When to use it?
16) What are singleton pattern and some more questions on it like if u extend this singleton class for another class how u call the methods? Instead of private constructor cant, I have it as protected etc.,
17) Make sure you learn some more patterns like Factory, Facade, Observer etc.,
18) What is the binary search?
19) What is a thread? Thread life cycle? Yield, wait, sleep etc., multithreading .. some logical questions.
20) Run vs runnable?
21) Concurrency package
22) Reflection package – what is it for and any sample implementations
23) What is a garbage collector? How it happens? Any algorithms you know like mark and sweep algo ? what is nursery? Can u invoke gc() is it safe to use?
24) Memory-related questions what is stack  mem , heap mem.. how the gc works on both and how objects move from one mem to other mem.
25) Cacheing.. what is cache? How can we implement our own cache? Have you used any caching? Some more ques like if i have heavy data with blob and clob related entries also how u perform caching.
26) If I have 100 threads and a synchronized block each thread is taking 30 sec but i want to improve my app performance so how u can solve it.
27) What is volatile means how it works
28) What is transient means how it works
29) What is marker interface? Examples of it and will you be able to create a marker interface?
30) What is serialization? How it works? What are the advantages of it? If i give transient what it does, what happens? If I implement serialization for base class and not for extended classes what happens and vice versa?
31) What is enumeration? Basic questions
32) What is system.out.println()? What is system? Out?
33) Generics? If u know other side <> or or etc questions
34) Any new features in java 5 what is it? Same quests for 6 and 7.
35) What is deadlock. Any deadlock prevention techniques
36) What is file stream, buffered readers
37) Collections? What is hashmap, hashtable, hashset, treeset, vector, linkedlist, arraylist, stack, queue etc.,
38) Some differences between them in 37 Q
39) Internal implementations of arraylist, linked list which is best for what i.e insertion , deletion, traversal etc
40) What is auto boxing, shadowing, deep copy, pass by value, pass by reference
41) Sorting, comparable, compare to method override. Person has emp name and all person obj in arraylist .. now sort arraylist by emp name
42) Without using any java packages and even util package implement stack, queue etc
43) What all packages you know and which packages are you comfortable in.
44) Equals and hashcode overriding. ... lot of questions on why we override and how we override. Do we have any contracts between both if so what.
45) Treeset is auto sorted right how it happens.
46) I want to write my own collection class with push pop so which one you implement or extend and how u write the methods...
47) What are differences between creational, structural and behavioural design patterns.
48) What is inner class? Some deep questions on inner classes? (Rare people ask)
49) What is multiple inheritance in java and any example for it?
50) More questions on overloading and overriding.
51) What is exception? And what is error?
52) Difference between exception and error? What is checked and unchecked exceptions?
53) Sample exceptions and errors and whats its purpose?
54) If out of memory error how u handle it?
55) How jvm creates a dump file for you?
56) Java –x parameters questions.
57) When u say java Mohan which is import x.mohan.Sub; and the same class available in two jars in class path then which one jvm considers.
58) What are wrapper classes?
59) MVC what is model, view and controller? Where we use it.
60) More questions on Compile time and run time. Like will i be able to catch outofmemory error if no why if yes how. If our answer is no then if i write the statement in catch an outofmemory error it thows complie time exception or runtime.
61) How can i create my own custom exceptions.
62) Difference between throws, throwable is it safe to use.
63) Code review related and some best practices related questions.
64) SQL Joins , trigger, index, clustered index, as a developer they give a scenario and ask on what u create indexes.
65) What are JSP implicit objects? I.e Request, response, pagecontext, application, session, out, config, page and exception.
66) What is priority queue, binary sort, binary tree, tree sort.
67) Given one binary tree...
      a. A has left B and right C
      b. B has left D and right E
      c. C has left F and right G
     d. How u write a program to make it mirror image.
68) Servlet life cycle
69) Will i be able to overwrite init method of servlet
70) How can i destroy a servlet
71) What is jsp life cycle
72) <@page , import , cache  related questions.
73) Web.xml questions like init params, context params , session, servlet filters etc.,
74) Select Null from Employee e;
75) What is Cartesian join.
76) Aptitude questions like
              a. 20 sheets -> 1 sheet -> 55 lines -> 1 line -> 65 chars. If i write 1 sheet -> 65 lines and 1 line 75 chars then how many sheets req?
77) 25 buckets of water to fill a tank ...
78) Green blue white balls et.c...
79) Super and this questions
80) Suppose class A has static int i =10; then Output of  A1.i, A2.i then change it to int i =20; then outputs and if i change value of i then outputs etc.,
81) Then Extends questions like A A1 = new A(); B B1=(B) A1; A A2 – new A(); B B2 = (B)A2();
82) Class A  public int i=10; class B public final A A1 = new A(); .... Main { B B1=new B(); B1.A1.i = 15; will it give any exception}
83) DOM Vs SAX Parser.
84) XML – simple type complex type
85) WSDL Structure what is soap envelope?
86) Marshalling and unmarshaling  .. Webservice bottom up and top-down approach.
87) SOAP, Document literal, RPC bindings
88) String s = “Hello”; String s1 = “Hello”;            == .equals gives what output what happens internally.                  String s = new String(“Hello”);   == .equals ??
89) Cloning / deep cloning ??
90) In a web application, how can i count how many requests are coming to a respective servlet.
91) Servlet Vs Portlet life cycle.
92) Portlet AJAX Implementation.
93) Servlets will have default no arg constructor or not.. if so can we initialize it with new operator?
94) Array[100] obj -> normal serialization is not used..  then how u can serialize this array.
95) If you serialize one object and then u modify that obj.. in that case if you deserialize that object it will give proper result or it will throw an exception.
96) Write a program to create a tree as shown below
             a. Root 21 has left 6 and right 15 as its sum is equal to root.
          b. 6 has left 2 and right 4 .. sum is 6
             c. 15 has left 7 and right 8 .. sum is 15.
97) SQL count will give count of null values also or not.
98) Delete vs truncate commands in SQL
99) Will you be able to catch Runtime exception in try catch and will you be able to throw runtime exception?
100) Can we give final to a singleton class.
101) Linkedhashmap?? Stringbuilder vs stringbuffer vs vector.
102) JDBC drivers type 1,2,3,4.
103) JSP tags etc..
104) Can you implement a remote contract where u have 5 buttons each button performs on and off of the item .. so how u store the state and alter the state from on to off .. vice versa. And moreover one Undo button.
105) What is an anonymous class?
106) Can we write an interface within a class?

            Useful Websites:
a. http://javapapers.com
b. http://www.brpreiss.com/books/opus5/index.html
c. http://www.tutorialspoint.com/java/java_serialization.htm
d. http://javarevisited.blogspot.in/2011/09/javalangoutofmemoryerror-permgen-space.html
e. http://www.brpreiss.com/books/opus5/html/page36.html


1)      Livelock vs deadlock vs Race Condition
2)      Design of a Vending Machine
3)      Given three integers – tell the small integer without using any relational operators.
4)      What is hash map internal implementation
5)      The singly linked list is given.. 2 4 56 77 now pointer is at 56 given a new number 40 which should be inserted before 56. How u can do it. No access to the head.
a.       Create a new node of 56 and insert next to 56 then update the current node value to 40 . So, it will be inserted easily.
6)      Binary search tree given x and y find the common ancestor.
7)      2 4 55 66 7 4 6 95 9 8….. Find the a and b values where a+b is 10 .Whereas a and b should be first two integers .. Write in a minimal and optimal way.
8)      Old feature phones has 0 to 9 like 0 4 special characters, 1 abc, 2, def etc with this when I give 149 you should print all the possible combinations which u can achieve using recursion or in an optimized way.
9)      How jvm loads the required classes into memory
10)   What are the different types of class loaders.
11)   Session management in jsp
12)   Life cycle of thread, servlet, jsp
13)   Implicit objects of jsp
14)   Custom jstl tag creation
15)   BFS algorithm
16)   Array list implementation
17)   Stack push pop min get the min value at any time in stack in an optimised way
18)   Message decoding program to decode the given problem for ex A 0 B 00 C 01 D 10 E 000 F.. so on then 11 or 111 is terminations and 000 is message termination to decode.. write a program to decode.
19)   Given a doubly linked list.. print the reverse doubly linked list only with one loop iteration
20)   What are concurrency and concurrent collections. What are the differences
21)   What is diff between hashmap, hashtable, concurrenthashmap
22)   Countdownlatch and cyclic barrier
23)   What is thread pool, object pool, connection pool
24)   What is the use of datasource vs db connection jdbc
25)   What is inner join, functions, other joins, queries, duplicates finding, top 2nd, equi or self joins, drop vs truncate vs delete, index? , views, stored procedures.
26)   What is the difference between mysql, oracle and ms sql
27)   What are the new features in Java 8
28)   Generics? T super, extends , exceptions
29)   Superclass of exception, custom exception. Can we create a custom runtime exception?
30)   Stack memory, heap memory.
31)   How to process a huge amount of data if required..
32)   -2 + 3*4/2 + 20 * 8 – 42 + 6 *8/10 – how u can process this?
33)   Splitwise.. multiple persons and multiple transactions, how we can simplify it such that u can settle them in less number of transactions...
34)   Given an unsorted array of integers. Find out the unique pairs where the difference between two numbers is the same and minimum of the entire given integers.
35)   If one method is synchronized and it is being accessed by thread t1 then thread t2 can access a non-synchronized method of that class. If so what kind of lock JVM will take how it works.
36)   Write a BFS / DFS algorithm
37)   Immutable object means. How we can create it. Any examples
38)   String s1 “abc” s2 “abc” hashmap.put s1, s2 “abc” as key with 3 different values, what will be the result
39)   Replace all banana in a sentence with ca but don’t use replace inbuilt functions.
40)   Serializable object means, transient, externalizable and its methods
41)   Differences between SOAP and REST web services and its use cases
42)   SOAP WSDL definition
43)   WS security implementation
44)   Eclipse JVM debug mode we see the current value. What is that option provided by JVM to see what option is it?
45)   If a string is given “ I am French boy” then another string is given like rnf then you should find the shortest substring which can contain only rnf . It may be Fren
46)   Clothes bar of N size and it is equally divided into N parts now each cloth of size x is put on the bar from a position I then you should finally say how many clothes are visible outside when u see it directly.
47)   SAX vs DOM Parser
48)   Amazon book page -> your approach to implementing that page in what way of HTTP request and response u handle it.

49)   Garbage collection heap management.


core java interview questions, j2ee interview questions, design interview questions, java questions.

Comments

Post a Comment

Popular Posts

Job Posting - Assistant Managers / Deputy Managers / Managers for Designs.

Dear Colleagues,Our present employees are considered as a very important recruitment base and for some positions they are even the primary source of recruitment.We are looking for Assistant Managers / Deputy Manager / Managers for Designs division, to be based at Chennai / Hyderabad / Mumbai. The incumbent should be a self motivated and self driven team leader who can lead a team of engineers and draughtsmen. The job involves design of Cement Plant and allied structures for Indian and International clients.Interested candidates may apply by e-mail to SRRS-IN@flsmidth.com (for openings in Mumbai and Chennai) and to KKB-IN@flsmidth.com (for openings in Hyderabad) with their detailed CV on or before 10 Feb 2010.The details of the openings are as follows :PositionAssistant Managers / Deputy Managers / ManagersDepartmentDesignsJob ResponsibilityAllocating designs / drafting to juniors / draughtsmenProviding necessary inputs to enable them to do the allocated work.Checking of desi…

DOT NET Interview Questions with Answers

When not to use Design Patterns?Do not use design patterns in any of the following situations.• When the software being designed would not change with time.• When the requirements of the source code of the application are unique.If any of the above applies in the current software design, there is no need to apply design patterns in the current design and increase unnecessary complexity in the design.When to use Design Patterns?Design Patterns are particularly useful in one of the following scenarios.• When the software application would change in due course of time.• When the application contains source code that involves object creation and event notification.Benefits of Design Patterns:The following are some of the major advantages of using Design Patterns in software development.• Flexibility• Adaptability to change• ReusabilityWhat are Design Patterns?A Design Pattern essentially consists of a problem in a software design and a solution to the same. In Design Patterns each pattern…

Visual Studio 2008 - Interview Questions with answers

New Features of Visual Studio 2008 for .NET Professionals1. LINQ Support

LINQ essentially is the composition of many standard query operators that allow you to work with data in a more intuitive way regardless.

The benefits of using LINQ are significant – Compile time checking C# language queries, and the ability to debug step by step through queries.

2. Expression Blend Support


Expression blend is XAML generator tool for silverlight applications. You can install Expression blend as an embedded plug-in to Visual Studio 2008. By this you can get extensive web designer and JavaScript tool.

3. Windows Presentation Foundation

WPF provides you an extensive graphic functionality you never seen these before. Visual Studio 2008 contains plenty of WPF Windows Presentation Foundation Library templates. By this a visual developer who is new to .NET, C# and VB.NET can easily develop the 2D and 3D graphic applications.

Visual Studio 2008 provides free game development library kits for games develo…

Walk-in interview on 27th March'10 in Bangalore @ TCS

Use this link, if unable to view the page Tata Consultancy Services (TCS) has endeavoured to help clients solve business challenges across diverse platforms and practices spread across multiple geographies. We, at TCS, offer you an opportunity to be a part of this dynamic team environment that is fulfilling, both professionally and personally.• "Industry Excellence Award 2008" (Institution of Engineers, India)
• "5-Year Multi-Million Dollar Deal" as ArvinMeritor's Global Engineering Partner
• "Best Use of Technology in Recruitment" (Recruiting and Staffing Best in Class -
     RASBIC Awards : 2009-2010)
Web Technologies

JAVA
– JAVA development experience

Microsoft Technologies (MS)

MOSS

.Net Designers
– Microsoft .Net, Oracle, IBM MQ
– Technical design experience
– Multi-engine/multithreading concepts
– Windows service experience

Business Intelligence / Knowledge Management (BI-KM)

Informatica Designer / Developer
– Informatica design / development experience

F…

.Net Framework Interview questions with answers

What do you know about BCL?The BCL (Base Class Library) is a combination of classes or we can say that it’s a library of functionalities and types available to all languages that used in .NET Framework. To make the programmer job more easier dot net gave a advantage to includes the BCL in order to collect a large number of common functions, just like to read a file and write to file, graphic rendering, database interaction, and XML document manipulation at one place . The scope of this is large and standard libraries for most other languages, including C++, and would be comparable in scope to the standard libraries is just like Java. The BCL is sometimes incorrectly referred to as the Framework Class Library (FCL), which is a superset including the Microsoft namespaces.In Assembly which work as GacBrowser ?The GACPicker class allows the user to select an assembly from the Global Assembly Cache. It does this by looking at the filesystem representation of the GAC, since there appears to…

ASP.NET 3.5 interview questions with answers

The IHttpHandler and IHttpHandlerFactory interfaces ?The IHttpHandler interface is implemented by all the handlers. The interface consists of one property called IsReusable. The IsReusable property gets a value indicating whether another request can use the IHttpHandler instance. The method ProcessRequest() allows you to process the current request. This is the core place where all your code goes. This method receives a parameter of type HttpContext using which you can access the intrinsic objects such as Request and Response. The IHttpHandlerFactory interface consists of two methods - GetHandler and ReleaseHandler. The GetHandler() method instantiates the required HTTP handler based on some condition and returns it back to ASP.NET. The ReleaseHandler() method allows the factory to reuse an existing handler.Does .NET CLR and SQL SERVER run in different process?Dot Net CLR and all .net realtes application and Sql Server run in same process or we can say that that on the same address be…

Contact Form

Name

Email *

Message *