java interview question set-1
1) Tell me about career profile and describe your one of the main project?
then deep drive into the current project.
Why u are using these technology like JMS, Concurrency, Spring in your application?
What feathers of java 1.6 you are using in your current application?
How you r managing concurrency in application?
How the exceptions are handled in your application?
2) Java collections - When to use ArrayList and Linked list?
If we require random access in collection and We have more read compare to updates we should go for Arraylist. Linked list is good for more updates and removals from collection.
Java Collection
3) Application wants to load static data with limited memory foot print and it should be refreshed after regular interval. Implement LRU Cache ?
LRU Cache is related to removal of cache which is not used for maximum time.
LRU Cache Implementation
4) What is soft reference, weak reference, phantom reference?
A weak reference, simply put, is a reference that isn't strong enough to force an object to remain in memory. Weak references allow you to leverage the garbage collector's ability to determine reachability for you, so you don't have to do it yourself. It is used in java.util.WeakHashMap.
A soft reference is exactly like a weak reference, except that it is less eager to throw away the object to which it refers. An object which is only weakly reachable (the strongest references to it areWeakReferences) will be discarded at the next garbage collection cycle, but an object which is softly reachable will generally stick around for a while.
A phantom reference is quite different than either SoftReference or WeakReference. The object is marked for Garbage collection but it is finalised and have not yet reclaimed. The object is called as phantom reachable. Its grip on its object is so tenuous that you can't even retrieve the object -- its get() method always returns null. The only use for such a reference is keeping track of when it gets enqueued into a ReferenceQueue, as at that point you know the object to which it pointed is dead.
5) How is memory management in java? how the heap is divided in different area?
Mainly heap is divided into Young generation, Old\Tenured Generation and Permanent Generation area.
Java Memory Mgmt
6) Where String literals are stored in heap?
They are stored in String pools in Permanent memory area.
Java Memory Mgmt
7) How to handle out of memory error and what tools we can use to figure out memory leaks?
Java Memory Mgmt
8) What is Synchronization and locks in java 1.5?
Java 1.5 features
9) Explain new features in java 1.5 and java 1.6?
Java 1.5 features
There are a few new features in Java 1.6, but not many:
@Override annotations on methods specified by an interface
NavigableSet, NavigableSet, Deque
Those are the changes that I can think of.
Wait, there's more:
Pluggable Annotation Processing
Programmatically access to the compiler through ToolProvider
10) How to do thread scheduling in java 1.5?
Java Concurrency
11) What are new concurrency classes in java 1.5?
Java Concurrency
12) Explain Singleton design pattern and what is double check locking (DCL) and how to make singleton classes using volatile?
Design Pattern [Singleton]
13) What is the difference between correlated subqueries and uncorrelated subqueries?
Uncorrelated subquery is that the subquery can be run independently of the outer query. Basically, the subquery has no relationship with the outer query.
example :
select * from employee where id in (select employee_id from department where dept_id=10);
Here sub query \ inner query is not dependent on outer query.
Correlated subquery has the opposite property – the subquery cannot be run independently of the outer query.
SELECT *FROM Employee Emp1
WHERE (1) = (
SELECT COUNT(DISTINCT(Emp2.Salary))
FROM Employee Emp2
WHERE Emp2.Salary > Emp1.Salary)
What you will notice in the correlated subquery above is that the inner subquery uses Emp1.Salary, but the alias Emp1 is created in the outer query. This is why it is called a correlated subquery, because the subquery references a value in it’s WHERE clause (in this case, it uses a column belonging to Emp1) that is used in the outer query.
14) If Parent class is Serializable, then Child class should be Serializable classs ?
yes, a subclass IS-A superclass, and hence child will also be IS-A Serializable too.
However, if the question is referring to an object actually being serializable, then maybe not, as it is possible for a subclass to provide readObject() and writeObject() methods, that thows a NotSerializableException.
Puzzle :
1) You are in one room at 5'th floor of building and it has 3 bulbs and the switch for these bulbs are in ground floor and you can go down only 1 time and Tell me how you know particular switch for each bulb? ,, tip --use bulb heating**
2) You have 1000 teams and each team plays knock out with each other, how many minimum matches we need to schedule to figure out winner?
3) Write the programme to get square root of 100? do not use java math Square root functions?
Management Round:
1) Tell me about yourself?
2) Why you want to leave current job?
3) Why you want to join this bank? ..[Get the history of bank and current CEO details and latest mergers]
4) Your key strengths and weakness?
5) Tell me how you were managing team?
HR Round:
1) Why would you like to leave current role?
2) What is your long term plan, how you would you like to growth your career?
[Answer of these Mgmt/HR Questions are listed here] Overall process took around 1.5 months from first round to final job offer. one more point there was onsite puzzle solving in first round using eclipse and we need to make Junit test cases to demonstrate the understanding of Test driven development.
More interview questions from investment bank job interviews
Interview Question set 1.
Interview Question set 2.
Interview Question set 3.
Interview Question set 5.
Important topic to prepare for Java interview:
1) JAVA 1.5 details
2) Java Collection Interview questions
3) XML Parsing
4) JDBC Interview Questions
5) Hibernate interview questions
6) Java Threading questions
7) Java Concurrency questions.
8) JMS interview questions.
9) Spring Framework
10) Java Design Pattern
Few More common interview questions
What is true about final class?
1) final class can't be extended .
2) A final method can't be overridden when its class is inherited.
3)You can't change value of a final variable (is a constant).
2,3 is correct
Only 1 is correct
1 & 2 is correct
1, 2 & 3 is correct
Ans : D
What if the static modifier is removed from the signature of the main() method
Compilation Error
Runtime Error
No issues
Not possible in java
Ans : B runtime throws an error "NoSuchMethodError".
When a class defines a method using the same name, return type, and arguments as a method in its superclass. This concept is called?
Overriding
Overloading
Inheritance
Association
Ans : A
In Java Objects are passed to method by?
Passed as referece
Passed as Value
Passed referece as Value
Both referece and Value is passed
Ans : C
What is use of Externalizable interface
Multithreading
Exception handling
Serialization
IO operation
Ans : C
What will be output of this code
try{
System.exit(0);
}
Catch(Exception e){
E.printstacktrace()
}
Finally {
System.out.println(" Finally Block");
}
SOP as "Finally Block"
Runtime Exception
Compilation Error
Program executes without any output
Ans : D
. How many objects are created in the following piece of code?
MyClass c1, c2, c3;
c1 = new MyClass ();
c3 = new MyClass ();
Three Objects
Two Objects
No Objects
One Object
Answer : B
How the values are stored in HashMap for particular Key
Using ArrayList
Using LinkedList
Using Object Arrays
Using Set
Answer B
9)Why does _jspService() start with an ‘_’ but other lifecycle methods do not?
A)This is special method for JVM to run
If it is override, the compiler gives an error
We rename to jspService()
None of above
26. What would be the result of 3+2+”7″ in java script?
12
57
5
7
Comments
Post a Comment