Saturday, October 13, 2012

Java Interview Questions for 2 to 3 years experience - Answered

Java Interview Questions 2 to 4 years experienced
If you are a Java programmer with 2 to 3 years experience of working in Java and looking for job change then its better to know what is expected from a 2 to 3 years experienced Java programmer in a typical core Java or J2EE interview. Since 2 to 3 years is not a huge experience and you still fall under beginner to intermediate category , its not expected from you to have done profiling, Garbage collection tuning or designing complex Java applications or even creating concurrent Java design pattern. What is expected from a 2 to 4 years experience guy in Java programming is sound knowledge of Java fundamental including OOPS concepts like Abstraction, Encapsulation, Polymorphism, Composition and Inheritance, good knowledge of Java collection API and familiarity with different kinds of collection e.g. List, Set and Map with some familiarity with popular Collection classes e.g. ArrayList, HashMap, Vector and HashSet etc. Fundamental knowledge of Java threading API, wait-notify mechanism and Exception handling in Java is also something Interviewer look in a intermediate Java programmer and of-course some basic programming and coding exercise e.g. finding length of linked List in one pass or reversing String in Java etc. If you manage to prepare these topics well, you are most likely to do well in Java interviews on service based companies e.g. Tech Mahindra, CapeGemini, CTS, Wipro, TCS etc.

In this Java interview question and answer article we will see some popular and tricky Java question asked with 2 to 3 or 4 years experienced Java developers in software developer interviews.

core Java Interview Questions and answers for 2 to 4 years experienced programmerQuestion 1) What is difference between Vector and ArrayList in Java?
Answer : One of the most popular Java question at 2 years experience level which aims to check your knowledge on Java collection API. key point to mention is synchronization and speed, since ArrayList is not synchronized its fast compare to Vector. See Vector vs ArrayList in Java for more difference between both of them.

Question 2) What is difference in LinkedList and ArrayList in Java?
Answer : If you don't get previous Java question then you are likely to get this question at 2 to 3 years experience level Java interview. Unlike synchronization, key point to mention here is underlying data structure. See LinkedList vs ArrayList in Java for detail answer of this java question.

3) What is difference between fail-fast and fail-safe Iterator in Java?
This is relatively new Java question compare to previous ones but increasingly getting popular into 2 to 3 years level Java interviews. key difference here is that fail-fast Iterator throw ConcurrentModificationException while fail-safe doesn't. See fail-safe vs fail-fast Iterator in Java for more differences between two.

4) Difference between throw and throws in Java?
This Java question belongs to Exception handling category which is another popular category for 2 to 4 years experienced Java programmer. Main difference between these two is that one declares exception thrown by a Java method while other is actually used to throw Exception. See Difference between throw and throws in Java for full answer of this Java exception handling question.

5) What is difference between checked and unchecked Exception in Java.
Another java interview question for 2 to 4 years experienced Java programmer from Exception handling. key point to mention here is that checked Exception requires mandatory exception handling code while unchecked doesn't. See  checked vs unchecked Exception in Java for more differences.

6) Write code to print Fibonacci series in Java?
You are bound to expect some coding interview question in Java interview for 2 to 4 years experience. Though Fibonacci series is one of the most classical and popular question not every Java programmer is able to do it correctly in interview, things get more complicated if interviewer ask to do this by using recursion. So better to prepare for approach, See how to write Java program for Fibonacci series using recursion for details and code example.

7) Write Java program to reverse String in Java without using StringBuffer?
Another Java coding interview question asked on 2 ot 4 years experienced Java developer. Many times interviewer specifically mentioned that you can not use StringBuffer because it has reverse() method which makes this taks trivial. So you must know how to do this by using iteration as well as recursion to perform well. Look at Java program to reverse String in Java for full code sample and explanation.

8) What is difference between Runnable and Thread in Java ?
Frequently asked Java interview question on 2 to 4 years experienced level from Threading fundamentals. there are two ways to implement Thread in Java, in fact three e..g extending java.lang.Thread class or implementing java.lang.Runnable or Callable interface. See Thread vs Runnable in Java for exact differences on following each approach.

9) What happens if you don't call wait and notify from synchronized block?
Another common Java interview question from multi-threding and inter thread communication. As I said earlier you must know concept of wait and notify in Java if you have worked for 2 to 3 years in Java. Check why wait and notify needs to call from synchronized block for exact reason to answer this Java question.

10) Write code to solve producer consumer problem in Java.
A good java question in my opinion which is mix of threading, synchronization, inter-thread communication and coding abilities. This particular java question can make any body's list at any day, not just 2 to 4 years experienced programmer. despite being so common it has something on it which confuse average programmer and allow you to differentiate between good and average programmer. See Producer consumer problem solving using BlockingQueue in Java for full code example.

These were 10 frequently asked Core Java interview question for 2 to 3 years experienced Java programmers. If you  want to increase numbers there are lot many questions floating around web for 2 to 3 or 2 to 4 years experienced Java developers but key things it to remember topics e.g. Collection, Exception handling, Coding, Threading and OOPS principles are the main areas from which most of 2 to 3 years experienced Java programmer interview question appear. Just get them right and you can crack any Java interview upto 2 to 4 years experienced Java programmer.

Other Java Interview articles from Java67 Blog

9 comments:

  1. Hi Javin i am working as a java developer in a company and i have 9 months of work ex i am trying to change my company can u tell me what all the interviewer can ask me and i am proficient in core java , jsp ,servlets .Plz do reply

    ReplyDelete
    Replies
    1. In which company you are currently working

      Delete
  2. m goin to attend my first experience interview.....what all the interviewer can ask me and i am proficient in core java , jsp ,servletsn anybody help me....specially related to project

    ReplyDelete
  3. I have 2 yrs experience in java . i am searching for the jobs . i have tried using Naukri.com but unable to get any interview call. if anyone can help please ?

    ReplyDelete
  4. Anybody having info regarding java <1 exp job opening..Please let me know at vishalgarg019@gmail.com

    ReplyDelete
  5. I am a 2013 passout fresher. But i know all the java/j2ee technologies and also the frameworks.So if any one wants to hire me then contact me - gopalrao601@gmail.com

    ReplyDelete

Java67 Headline Animator