Skip to main content - A Private Search Engine Your searches should be private. We make sure they really are.  Private Search in Action  We don’t track you  We don’t store your searches in any identifiable way  We don’t store your IP address in our services Your privacy is important.  There are no traces of your activities and personal identity in our servers.  You can learn more about privacy in our blog  We don't like cookies!

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:

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.


Post a Comment

Popular Posts

Free Softwares 09 July 09

JDownloader JDownloader, open source and platform independent, can help download files from file hosters like, and others. JDownloader can be used by both kinds of users - those who have a premium account and those who don't pay. Features: Support for many file hosting sites, decrypt plug-ins for many services. e.g., UCMS, WordPress, skips the limits of Filehosting websites, downloads in multiple paralell streams, download with multiple connections, captcha recognition, automatical file extraction, Can download Youtube, Vimeo, clipfish video, and Mp3 files; 24-hour support, integrates with Firefox, no installation needed, and more. The 15.6 MB JDownloader, v.0.6.193, cross-platform - works on Windows, Linux and Mac OS X, can be downloaded at Runs on Java 1.5 or higher. jGnash jGnash is a free personal finance manager with many features available in commercial versions. Main Features

.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

Freewares / Free Softwares 04 March 10

FinalBurner The freeware version of FinalBurner can be a decent alternative to expensive CD and DVD burners. It can help burn data, audio, and video onto CD R/RW, DVD+R/RW, DVD-R/RW, DVD DL. An ISO image of a disk can be created as well. Designed with no bells and whistles, FinalBurner' s simple user interface makes the process of CD recording quite easy. Its main features include: Burn Data CD/DVD (CD R/RW, DVD+R/RW, DVD-R/RW, DVD DL, HD-DVD, Blu-Ray, etc.); Autorun menu designer; Burn Audio CD (Import *.wav; *.mp3; *.ogg; *.mid; *.wma; *.aac; *.mp4; *.m4a; *.xm; *.mod; *.s3m; *.it; *.mtm; *.mo3 audio files.); Burn Video DVD (Import AVI, DIVX, XVID, MP4, MPG, WMV, ASF, MOV, FLV, etc; Capture from Web cam, TV tuner, DV, etc.); and Audio Cd Ripping. The 9 MB FinalBurner v2.18.0.181 (February 19, 2010) for WinXP, Windows2000, Windows2003, Windows Vista, WinNT 4.x, Windows Media Center Edition 2005, Windows Vista, Windows Vista x64, can be downloaded at http://www.videodvd

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 • Reusability What are Design Patterns? A Design Pattern essentially consists of a problem in a software design and a solutio

Software: XBMC

XBMC is an award-winning free and open source (GPL) software media player and entertainment hub for digital media. Currently XBMC can be used to play almost all popular audio and video formats around. It was designed for network playback, so you can stream your multimedia from anywhere in the house or directly from the internet using practically any protocol available. Use your media as-is: XBMC can play CDs and DVDs directly from the disk or image file, almost all popular archive formats from your hard drive, and even files inside ZIP and RAR archives. It will even scan all of your media and automatically create a personalized library complete with box covers, descriptions, and fanart. There are playlist and slideshow functions, a weather forecast feature and many audio visualizations. Once installed, your computer will become a fully functional multimedia jukebox. XBMC is available for Linux, OSX, and Windows, and can be downloaded at http://xbmc.or

Contact Form


Email *

Message *