DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Oracle NoSQL Database: A Comprehensive Guide for Developers
  • Microsoft Teams for Developers: Enhancing Communication With Call Initiating and Recording
  • Mastering Thread-Local Variables in Java: Explanation and Issues
  • Migrating From Lombok to Records in Java

Trending

  • Testing SingleStore's MCP Server
  • The Human Side of Logs: What Unstructured Data Is Trying to Tell You
  • Automating Data Pipelines: Generating PySpark and SQL Jobs With LLMs in Cloudera
  • The Cypress Edge: Next-Level Testing Strategies for React Developers
  1. DZone
  2. Culture and Methodologies
  3. Career Development
  4. 10 Tricky Interview Questions for Java Devs

10 Tricky Interview Questions for Java Devs

Here's a list of ten popular interview questions that Java developers are likely to be asked in an interview, as well as links to relevant explanations for more details.

By 
Ajitesh Kumar user avatar
Ajitesh Kumar
·
Dec. 18, 17 · Presentation
Likes (20)
Comment
Save
Tweet
Share
165.0K Views

Join the DZone community and get the full member experience.

Join For Free

Here is a list of 10 tricky/popular interview questions and answers for Java developers. I got these questions out from StackOverflow. You are a junior or intermediate level Java developer and are planning to appear for interviews in the near future, you would probably find these questions to be useful enough.

Q1: Is Java “pass-by-reference” or “pass-by-value”?

Ans: Java is always “pass by value”. Read the details on this page, Is Java “pass-by-reference” or “pass-by-value”?

Q2: How can you create a memory leak in Java?

Ans: This is possible by making use of a class loader and ThreadLocal. Read the details on this page, Creating a memory leak in Java

Q3: What is the difference between package private, public, protected, and private?

Ans:

  • A private member variable is accessible within the same class.

  • A package private variable (member variable with no access specifier) is accessible within all classes in the same package.

  • A protected variable is accessible within all classes in the same package and within subclasses in other packages.

  • A public member is accessible to all classes.

Read more details on this page.

Q4: What are two differences between a HashMap and a Hashtable?

Ans: A Hashtable is synchronized and does not allow null keys or values. Read more details on this page: differences between HashMap and Hashtable.

Q5: What are different techniques for avoiding != null statements (Not Null Check)?

Ans: Usage of assert statements is one way. Custom annotations can also be defined for NotNull checks. See more details on this page: How to avoid != null Statements.

Q6: Does “finally” always execute in Java?

Ans: Not in a scenario such as an invocation of a “System.exit()” function, an infinite loop, or system crash, etc. More details can be found here: Does finally always execute in Java?

Q7: Is it possible to call one constructor from another in Java?

Ans: Yes, but one can only chain to one constructor — and it has to be the first statement in your constructor body. More details can be found on this page: How do I call one constructor from another in Java?

Q8: Which one should be used, “implements Runnable” vs. “extends Thread”?

Ans:“Implements Runnable” is the preferred way. Read further details here: Implements Runnable vs. Extends Thread

Q9: Is it possible to break out of nested loops in Java?

Ans: Yes, and here is an example of how to do it: Breaking out of nested loops in Java.

Q10: What is reflection and why is it useful?

Ans: Reflection is used to describe code that is able to inspect other code in the same system. Read the reasons for doing so here: Why Reflection is useful.

Java (programming language) dev Interview (journalism)

Published at DZone with permission of Ajitesh Kumar, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Oracle NoSQL Database: A Comprehensive Guide for Developers
  • Microsoft Teams for Developers: Enhancing Communication With Call Initiating and Recording
  • Mastering Thread-Local Variables in Java: Explanation and Issues
  • Migrating From Lombok to Records in Java

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!