Monday, September 11, 2023

Top 10 Java Interview Questions for 2 to 3 years experience - Answered

Java Interview Questions 2 to 4 years of experience
If you are a Java programmer with 2 to 3 years experience of working in Java and looking for a job change then it's better to know what is expected from 2 to 3 years experienced Java programmer in a typical core Java or J2EE interview. Since 2 to 3 years is not a vast experience and you still fall under beginner to the intermediate category, it's not expected from you to have done profiling, Garbage collection tuning, designing complex Java applications, or even creating concurrent Java design patterns

What is expected from a 2 to 4 years experience guy in Java programming is a sound knowledge of Java fundamentals including OOPS concepts like Abstraction, Encapsulation, Polymorphism, Composition, and Inheritance, a good understanding of Java collection API, and familiarity with different kinds of collections like 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, the wait-notify mechanism, and Exception handling in Java is also something the Interviewer look at in an intermediate Java programmer and of course some basic at programming and coding exercise like finding the length of a 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, Capgemini, CTS, Wipro, TCS, etc.

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

But, if you are new to the Java world then I highly recommend you to check out The Complete Java Masterclass course to fill the gaps in your learning. This 80-hour long course is the best and most up-to-date course to learn Java. 





Top 10 Java Interview Questions 2 to 4 years of experience

Without wasting any more of your time, here is the list of top 10 Java interview questions for 2 to 4 years of experience programmers:

Question 1. What is the difference between Vector and ArrayList in Java?

Answer: One of the most popular Java questions at 2 years experience level which aims to check your knowledge on Java collection API. a key point to mention is synchronization and speed since ArrayList is not synchronized fast compared to Vector. See Vector vs ArrayList in Java for more differences between both of them.

Question 2. What is the difference between LinkedList and ArrayList in Java?

Answer: If you don't get a previous Java question then you are likely to get this question at 2 to 3 years experience level Java interview. Unlike synchronization, the key point to mention here is the underlying data structure. See LinkedList vs ArrayList in Java for a detailed answer to this java question.

core Java Interview Questions and answers for 2 to 4 years experienced programmer


3. What is the difference between fail-fast and fail-safe Iterator in Java?

This is a relatively new Java question compared to previous ones but increasingly getting popular in 2 to 3 years level Java interviews. the key difference here is that fail-fast Iterator throws ConcurrentModificationException while fail-safe doesn't. See fail-safe vs fail-fast Iterator in Java for more differences between the two.

4. Difference between throw and throws in Java?

This Java question belongs to the Exception handling category which is another popular category for 2 to 4 years experienced Java programmers. The main difference between these two is that one declares exceptions thrown by a Java method while the other is actually used to throw Exceptions. See the Difference between throw and throws in Java for a full answer to this Java exception handling question.

5. What is the difference between checked and Unchecked Exceptions in Java.

Another java interview question for 2 to 4 years experienced Java programmer from Exception handling. the 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 the Fibonacci series in Java?

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

7. Write a Java program to reverse String in Java without using StringBuffer?

Another Java coding interview question asked on 2 to 4 years of experience in Java development. Many times interviewer specifically mentioned that you can not use StringBuffer because it has a reverse() method which makes these tasks trivial. So you must know how to do this by using iteration as well as recursion to perform well. Look at the Java program to reverse String in Java for a full code sample and explanation.

8. What is the difference between Runnable and Thread in Java?

Frequently asked Java interview questions on 2 to 4 years experience level from Threading fundamentals. there are two ways to implementing 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 in following each approach.




9. What happens if you don't call wait and notify from the synchronized block?

Another common Java interview question is from multi-threading and inter-thread communication. As I said earlier you must know the 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 a synchronized block for the exact reason to answer this Java question.


10. Write code to solve the producer-consumer problem in Java.

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

Top 10 Java Interview Questions for 2 to 3 years experience - Answered



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

Thanks for reading this article so far. If you find these core Java Interview questions for 2 to 3 experienced programmers then please share them with your friends and colleagues. If you have any questions or feedback then please drop a note.  

32 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. Sun Microsystems

      Delete
    3. Until you don't have strong reason to change or contract period is over, don't go for it. Stay in one company at least for 2 years, If you change in short time, next company really doubt about your commitment part.

      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
    Replies
    1. Still U did not get any job mail your resume to srinathchintha@gmail.com I will refer in my company.

      Delete
    2. Which company

      Delete
  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
  6. I have 5 years of java experience in developing web application using Struts & EJB, JSP, Servlet.
    I struggle a lot for job change not able to clear any of the interview still.
    I don't know what is the interviewer's expectation.

    ReplyDelete
  7. @July 30, 2014 Anonymous person don't be disappointed someday you will crack it. Just make some time and read all the articles in this beautiful blog, I was in the same position it really helped me and it would do to you too ;)

    ReplyDelete
  8. Anonymous, I know what you mean. These interview questions are dumb. Anyone who just did a first year course in Java could probably answer those questions. Does that say anything about their performance? No, just means you do well at answering those questions.

    ReplyDelete
  9. ya this is the nice information for 2-3 year exp devlopers

    ReplyDelete
  10. All these questions are for freshers only.

    ReplyDelete
  11. Please Try to Put a Button called Download , so that we can download the Interview Quesions PDFs from that , which helps us a lot in interviews..

    ReplyDelete
  12. am 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
  13. Hi Guys,

    I am deepa and having 1.9 yrs exp in Android, now working in Noida since last 7 months. Now i want to change my job bcoz i have to learn more but in my current company has limitted work they have small small projects that's why i am searching job in Noida location.... So if anyone wants to hire me please contact to me at deepa14bharti@gmail.com

    ReplyDelete
  14. Hi,

    I am having work experience of 2 year in TCS but as a network administrator, but I want to change my domain to JAVA as I am passionate about coding and JAVA, kindly suggest me how I should prepare for interview and what are the things I should study before I go to any interview. I have knowledge of Core Java, JSP, Servlet and also knowledge of different languages but I was confident on these languages before 2 year. Please suggest me how I should start preparation and that should take less time as i am looking for switch asap.

    ReplyDelete
    Replies
    1. Hello, you can just go though all list of interview questions I have in this blog and Javarevisited, this will give you enough experience and broad your knowledge. They will also help you to familiar with essential Java concepts e.g. multi-threading, collection, GC, JVM internals etc. Once you are comfortable with popular questions, you can start applying. It will take a couple of interviews but slowly you will pick it up and finally get the job you want.

      Delete
  15. I have 1 and 4 month experience as java developer so please tell me should I switch this?

    ReplyDelete
    Replies
    1. I personal don't think so , you should look for a switch, since their are chances big ventures may spoil your profile, less then 2 years in Java development they consider it as a fresher only , so complete your at least 2 years and then prepare well get good offers then only switch.

      Delete
  16. Hello All, I Have 2.5 years of experience in java developer, i have completed numbers of small projects individually and i have strong oops concept, i already left my previous company on nov 2017 and right now i am unable to find and crack interview, lots of time i gone to last round then rejected, any one please help me , since 3 months i am jobless and doing privately projects for servive , what interviewer things y they rejected i dont know may be they want spring and struct experience.now days lots of company want skills of spring and hibernate. please help me what i do now and how to clear interview . i am ready to relocate any where in india.

    ReplyDelete
    Replies
    1. You just learn basic spring concept, and create a small small projects using spring with Java, then you can apply

      Delete
  17. Very informative article.
    I'm looking for a job change as java developer with experience of 2.5
    Kindly help me in getting referral.
    It's highly appreciated.

    ReplyDelete

Feel free to comment, ask questions if you have any doubt.