Categories: FreshersJava

Java Interview Questions (Part 1) – Rookies Series

The article (first in the series) aims to present some tricky interview Java questions that could help you score high in your next Java interviews:

  

Programming fundamentals

  

Java Objects

  

Collections
  • Question: What is difference between LinkedList and ArrayList? When would you want to use one and not the other?
    Answer: http://javarevisited.blogspot.in/2012/02/difference-between-linkedlist-vs.html
  • Question: How come you keep on adding objects in an ArrayList using add method and no exception is ever thrown? Could you think about underlying code?
    Answer: Take a look at the pictures below. The magic happens in the ensureCapacity method where a new arrayList is created, the elements from old arraylist is copied to new one and reference of new arraylist is assigned to member variable (elementData).

    fig: java arraylist add method

  • Question: What is difference between a Set and a List?
    Answer: The primary difference is that Set is a collection that consists of no duplicate elements or, in other words, consists of all unique elements.  Read further on the following page:
    http://stackoverflow.com/questions/1035008/what-is-the-difference-between-set-and-list

  

Exception Handling

  

Others

 

[adsenseyu1]
Ajitesh Kumar

I have been recently working in the area of Data analytics including Data Science and Machine Learning / Deep Learning. I am also passionate about different technologies including programming languages such as Java/JEE, Javascript, Python, R, Julia, etc, and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data, etc. For latest updates and blogs, follow us on Twitter. I would love to connect with you on Linkedin. Check out my latest book titled as First Principles Thinking: Building winning products using first principles thinking. Check out my other blog, Revive-n-Thrive.com

View Comments

Recent Posts

Logistic Regression in Machine Learning: Python Example

Last updated: 26th April, 2024 In this blog post, we will discuss the logistic regression…

21 hours ago

MSE vs RMSE vs MAE vs MAPE vs R-Squared: When to Use?

Last updated: 22nd April, 2024 As data scientists, we navigate a sea of metrics to…

2 days ago

Gradient Descent in Machine Learning: Python Examples

Last updated: 22nd April, 2024 This post will teach you about the gradient descent algorithm…

5 days ago

Loss Function vs Cost Function vs Objective Function: Examples

Last updated: 19th April, 2024 Among the terminologies used in training machine learning models, the…

1 week ago

Model Parallelism vs Data Parallelism: Examples

Last updated: 19th April, 2024 Model parallelism and data parallelism are two strategies used to…

1 week ago

Model Complexity & Overfitting in Machine Learning: How to Reduce

Last updated: 4th April, 2024 In machine learning, model complexity, and overfitting are related in…

2 weeks ago