SlideShare a Scribd company logo
37 Java Interview
Practice Questions
What is the difference between String,
StringBuffer, and StringBuilder in
Java?
Question 1:
How do you run a Java application
on the command line and set the
classpath with multiple jars?
Question 2:
What is the difference between final,
finalize, and finally?
Question 3:
How does Garbage Collection
prevent a Java application from
going out of memory?
Question 4:
What is the difference between a
ClassNotFoundException a n d
NoClassDefFoundError?
Question 5:
Why isn't String's .length() accurate?
Question 6:
Given two double values d1, d2, why isn’t it reliable to
test their equality using:

Question 7:
d1 == d2
What is the problem with this code:
Question 8:
final byte[] bytes = someString.getBytes();
What is the JIT?
Question 9:
final double d = 1 / 2;
System.out.println(d);
Question 10:
Why does
Print 0? How can you make the code print
0.5 instead?
IntStream.range(0, 10).forEach(System.out::println);
Question 11:
In this code:
what is the inferred type of the method
reference System.out::println?
final Path path = Paths.get(...);
Files.lines(path).forEach(System.out::println);
Question 12:
What is the problem with this code:
What will be the contents of the list after this
operation and why?
Question 13:
final List<Integer> list = new ArrayList<>();
list.add(1);
list.add(2);
list.add(3);
list.remove(2);
Write a function to detect if two strings are
anagrams (for example, SAVE and VASE)
Question 14:
What is the contract between equals and
hashCode of an object?
Question 15:
Can an enum be extended?
Question 16:
How threadsafe is enum in Java?
Question 17:
How does a JVM handle storing local
variables vs storing objects?
Question 18:
Identify the problem in the following code:
Question 19:
public class Foo {
public Foo() {
doSomething();
}
public void doSomething() {
System.out.println("do something acceptable");
}
}
public class Bar extends Foo {
public void doSomething() {
System.out.println("yolo");
Zoom zoom = new Zoom(this);
}
}
When do you use volatile variables?
Question 20:
Why do you need to use synchronized
methods or blocks?
Question 21:
What is the difference between HashMap and
ConcurrentHashMap?
Question 22:
When do you need to override the equals
and hashCode methods in Java?
Question 23:
What is a service?
Question 24:
What is a good usecase of calling
System.gc()?
Question 25:
What is the marker interface in Java?
Question 26:
How are Annotations better than a Marker
Interfaces?
Question 27:
What are checked and unchecked
exceptions? When do you use them?
Question 28:
int a = 1L; Won’t compile and
int b = 0; b += 1L; compiles fine.
Why ?
Question 29:
Why aren’t you allowed to extend more than
one class in Java but are allowed to
implement multiple interfaces?
Question 30:
Question 31:
Test t = null;
t.someMethod();
public static void someMethod() {
...
}
Why doesn’t the following code generate a
NullPointerException even when the
instance is null?
Question 32:
public class Test
{
public static void main(String[] args)
{
Integer a = 1000, b = 1000;
System.out.println(a == b);
Integer c = 100, d = 100;
System.out.println(c == d);
}
}
why does the first case print false while the
second case prints true?
Question 33:
String s1="home";
String s2="mohe";
How do you check whether or not the following two
strings are anagrams?
How do you reverse String("Java
Programming") without using Iterations
and Recursions?
Question 34:
Give real world examples of when to use an
ArrayList and when to use LinkedList
Question 35:
What is the difference between an Iterator
and a ListIterator?
Question 36:
What is the advantage of a generic
collection?
Question 37:
Did you know how to answer all 37 questions?
Feel free to check your answers here
or
schedule a mock interview with
an experienced Java developer

More Related Content

What's hot (20)

PDF
Class notes(week 9) on multithreading
Kuntal Bhowmick
 
PPT
Core Java interview questions-ppt
Mayank Kumar
 
DOCX
Interview Questions and Answers for Java
Garuda Trainings
 
PDF
201 core java interview questions oo ps interview questions - javatpoint
ravi tyagi
 
DOCX
Design pattern application
gayatri thakur
 
DOC
Questions of java
Waseem Wasi
 
PDF
Java Concurrency Starter Kit
Mark Papis
 
PDF
Java interview question
varatharajanrajeswar
 
PPTX
Java interview questions 2
Sherihan Anver
 
DOCX
C# interview quesions
Shashwat Shriparv
 
PDF
Concurrency on the JVM
Bernhard Huemer
 
PDF
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007
Arun Kumar
 
PDF
EEE oops Vth semester viva questions with answer
Jeba Moses
 
PPT
Top 10 Interview Questions For Java
EME Technologies
 
PPTX
Java interview questions 1
Sherihan Anver
 
PDF
Java design pattern tutorial
Ashoka Vanjare
 
DOC
C# interview questions
Chetan Chaudhari
 
DOCX
Core java questions
Pradheep Ayyanar
 
DOCX
Java Core
Gaurav Mehta
 
PPTX
Top 20 c# interview Question and answers
w3asp dotnet
 
Class notes(week 9) on multithreading
Kuntal Bhowmick
 
Core Java interview questions-ppt
Mayank Kumar
 
Interview Questions and Answers for Java
Garuda Trainings
 
201 core java interview questions oo ps interview questions - javatpoint
ravi tyagi
 
Design pattern application
gayatri thakur
 
Questions of java
Waseem Wasi
 
Java Concurrency Starter Kit
Mark Papis
 
Java interview question
varatharajanrajeswar
 
Java interview questions 2
Sherihan Anver
 
C# interview quesions
Shashwat Shriparv
 
Concurrency on the JVM
Bernhard Huemer
 
Lulu.com.java.j2 ee.job.interview.companion.2nd.edition.apr.2007
Arun Kumar
 
EEE oops Vth semester viva questions with answer
Jeba Moses
 
Top 10 Interview Questions For Java
EME Technologies
 
Java interview questions 1
Sherihan Anver
 
Java design pattern tutorial
Ashoka Vanjare
 
C# interview questions
Chetan Chaudhari
 
Core java questions
Pradheep Ayyanar
 
Java Core
Gaurav Mehta
 
Top 20 c# interview Question and answers
w3asp dotnet
 

Viewers also liked (20)

PDF
29 Essential AngularJS Interview Questions
Arc & Codementor
 
PPTX
25 php interview questions – codementor
Arc & Codementor
 
PPTX
Django Interview Questions and Answers
Python Devloper
 
PDF
Ingesting Drone Data into Big Data Platforms
Timothy Spann
 
PPT
Job Interview By Pair Programming
Abel Shen
 
PDF
ConcurrentHashMap Code Reading
Naoyuki Kakuda
 
PPT
Registry Part 5and6
woor6j
 
PDF
Solid scala
Knoldus Inc.
 
PPTX
eXtreme Tuesday Club at Pivotal Labs ft. Speemdnet / San Francisco - SEP 2015
Speedment, Inc.
 
PDF
Build App with Nodejs - YWC Workshop
Sarunyhot Suwannachoti
 
PPT
Registry Part 3
woor6j
 
PDF
Five Ways to Scale your API Without Touching Your Code
3scale
 
PDF
Django in Windows
Python Devloper
 
PDF
Realtime statistics using Java, Kafka and Graphite
Hung Nguyen
 
PPT
Java Threads and Concurrency
Sunil OS
 
PDF
Refactoring to Java 8 (QCon New York)
Trisha Gee
 
PDF
Introduction to django
Ilian Iliev
 
PPTX
Top 10 architect interview questions and answers
WhitneyHouston012
 
PPTX
20 iOS developer interview questions
Arc & Codementor
 
PPTX
Pivotal Tracker - Quick Start Guide
Amit Ranjan
 
29 Essential AngularJS Interview Questions
Arc & Codementor
 
25 php interview questions – codementor
Arc & Codementor
 
Django Interview Questions and Answers
Python Devloper
 
Ingesting Drone Data into Big Data Platforms
Timothy Spann
 
Job Interview By Pair Programming
Abel Shen
 
ConcurrentHashMap Code Reading
Naoyuki Kakuda
 
Registry Part 5and6
woor6j
 
Solid scala
Knoldus Inc.
 
eXtreme Tuesday Club at Pivotal Labs ft. Speemdnet / San Francisco - SEP 2015
Speedment, Inc.
 
Build App with Nodejs - YWC Workshop
Sarunyhot Suwannachoti
 
Registry Part 3
woor6j
 
Five Ways to Scale your API Without Touching Your Code
3scale
 
Django in Windows
Python Devloper
 
Realtime statistics using Java, Kafka and Graphite
Hung Nguyen
 
Java Threads and Concurrency
Sunil OS
 
Refactoring to Java 8 (QCon New York)
Trisha Gee
 
Introduction to django
Ilian Iliev
 
Top 10 architect interview questions and answers
WhitneyHouston012
 
20 iOS developer interview questions
Arc & Codementor
 
Pivotal Tracker - Quick Start Guide
Amit Ranjan
 
Ad

Similar to 37 Java Interview Questions (20)

PDF
Java Interview Questions
soniajessica2
 
PDF
Fnt software solutions placement paper
fntsofttech
 
PDF
Top 1000 Java Interview Questions_ Includes Spring, Hibernate, Microservices,...
AJEET KUMAR
 
PDF
Top 1000 Java Interview Questions Includes Spring, Hibernate, Microservices, ...
Ankit Kumar
 
PDF
Java Interview Questions for 10+ Year Experienced PDF By ScholarHat
Scholarhat
 
PDF
Java Interview Questions PDF By ScholarHat
Scholarhat
 
PDF
__ Java Technical round questions .pdf soo
Rajkumar751652
 
PPT
Java interview-questions-and-answers
bestonlinetrainers
 
PDF
Javainterviewquestions 110607071413-phpapp02
Kumaran K
 
PDF
Javainterviewquestions 110607071413-phpapp02
lakk1234
 
DOCX
Java interview questions
amit kumar
 
DOC
Core java interview questions1
Lahari Reddy
 
DOCX
Jist of Java
Nikunj Parekh
 
DOCX
JAVA CONCEPTS AND PRACTICES
Nikunj Parekh
 
PDF
Core java interview questions and answers
Sunil Soni
 
PDF
Java_Question-Bank.docx-1.pdf
Nguyen Huu Thuong
 
PDF
Java MCQ Important Questions and Answers
SONU HEETSON
 
DOC
MX Server is my friend
Gabriel Daty
 
DOC
MX Server is my friend
Gabriel Daty
 
DOC
MX Server is my friend
Gabriel Daty
 
Java Interview Questions
soniajessica2
 
Fnt software solutions placement paper
fntsofttech
 
Top 1000 Java Interview Questions_ Includes Spring, Hibernate, Microservices,...
AJEET KUMAR
 
Top 1000 Java Interview Questions Includes Spring, Hibernate, Microservices, ...
Ankit Kumar
 
Java Interview Questions for 10+ Year Experienced PDF By ScholarHat
Scholarhat
 
Java Interview Questions PDF By ScholarHat
Scholarhat
 
__ Java Technical round questions .pdf soo
Rajkumar751652
 
Java interview-questions-and-answers
bestonlinetrainers
 
Javainterviewquestions 110607071413-phpapp02
Kumaran K
 
Javainterviewquestions 110607071413-phpapp02
lakk1234
 
Java interview questions
amit kumar
 
Core java interview questions1
Lahari Reddy
 
Jist of Java
Nikunj Parekh
 
JAVA CONCEPTS AND PRACTICES
Nikunj Parekh
 
Core java interview questions and answers
Sunil Soni
 
Java_Question-Bank.docx-1.pdf
Nguyen Huu Thuong
 
Java MCQ Important Questions and Answers
SONU HEETSON
 
MX Server is my friend
Gabriel Daty
 
MX Server is my friend
Gabriel Daty
 
MX Server is my friend
Gabriel Daty
 
Ad

More from Arc & Codementor (10)

PDF
Remote Career Summit 2020 - the State of Remote Jobs - Weiting Liu of Arc
Arc & Codementor
 
PDF
Introduction to Python for Data Science
Arc & Codementor
 
PDF
Top 10 Programming Languages in 2015
Arc & Codementor
 
PDF
How to Build Your App from Scratch
Arc & Codementor
 
PDF
Angular meteor for angular devs
Arc & Codementor
 
PDF
Tmux tips and_tricks
Arc & Codementor
 
PDF
Introduction to Tmux - Codementor Tmux Office Hours Part 1
Arc & Codementor
 
PPTX
Codementor Office Hours with Eric Chiang: Stdin, Stdout: pup, Go, and life at...
Arc & Codementor
 
PDF
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Arc & Codementor
 
PPTX
Python Internals Optimization Choices Made - Codementors Office Hours with St...
Arc & Codementor
 
Remote Career Summit 2020 - the State of Remote Jobs - Weiting Liu of Arc
Arc & Codementor
 
Introduction to Python for Data Science
Arc & Codementor
 
Top 10 Programming Languages in 2015
Arc & Codementor
 
How to Build Your App from Scratch
Arc & Codementor
 
Angular meteor for angular devs
Arc & Codementor
 
Tmux tips and_tricks
Arc & Codementor
 
Introduction to Tmux - Codementor Tmux Office Hours Part 1
Arc & Codementor
 
Codementor Office Hours with Eric Chiang: Stdin, Stdout: pup, Go, and life at...
Arc & Codementor
 
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Arc & Codementor
 
Python Internals Optimization Choices Made - Codementors Office Hours with St...
Arc & Codementor
 

Recently uploaded (20)

PPTX
Resume-Writing-Workshop powerpoint Presentation
nmorales22
 
PDF
Mastering-Reactjs-Your-Path-to-Web-Development.pdf
sagarheddurshettyvio
 
PDF
Stefano_Zorzi_Curriculum_short_english.pdf
stefanogeomzorzi
 
PDF
Crafting Winning CVs Cover Letters and Mastering Job Interviews with Roman Vi...
Excellence Foundation for South Sudan
 
PPTX
Chemistry-Presentation-The-World-of-Silicates.pptx
swethasejal123
 
PDF
VisionIAS - UPSC GS Paper I Question Paper 2025 with Answer Key.pdf
saxenashubh937
 
PDF
Why Agentops requires an artificial Intelligence developer.pdf
ssiddhant550
 
PPTX
21st-Literature.pptxjsududhshsusushshsusuhsgsysh
JohnVJLBellen
 
PDF
Formwalaa: Your One-Stop Hub for Exam & Job Application Forms
Reeshna Prajeesh
 
PPTX
Web Developer Jobs in Jaipur Your Gateway to a Thriving Tech Career in Rajast...
vinay salarite
 
PDF
Jimmy Swaggart:Rise,Fall,and Rédemption.
Jimmy carter
 
PDF
Jai resume COME WAY FOR KNOWLEDGE IN THE.pdf
kunal946067
 
PPTX
Canopy Manipulation For Optimum Utilization of Light.pptx
vishalpatidar74
 
DOCX
PMCF (Performance Monitoring and Coaching Form
ROSALIESOMBILON
 
PPTX
100%复刻西班牙学历认证范本科尔多瓦大学成绩单防伪UCO学费单
Taqyea
 
PPTX
Learn AI in Software Testing - Venkatesh (Rahul Shetty)
Venkatesh (Rahul Shetty)
 
PPTX
Mastering the Cloud with AWS: A Deep Dive into Amazon Web Services
cbitssnavjotdm
 
PDF
NotificationForTheTeachingPositionsAdvt012025.pdf
sunitsaathi
 
PPTX
Ganesh Mahajan Digital marketing Portfolio.pptx
ganeshmahajan786
 
PDF
Stefano_Zorzi_Curriculum_short_english.pdf
stefanogeomzorzi
 
Resume-Writing-Workshop powerpoint Presentation
nmorales22
 
Mastering-Reactjs-Your-Path-to-Web-Development.pdf
sagarheddurshettyvio
 
Stefano_Zorzi_Curriculum_short_english.pdf
stefanogeomzorzi
 
Crafting Winning CVs Cover Letters and Mastering Job Interviews with Roman Vi...
Excellence Foundation for South Sudan
 
Chemistry-Presentation-The-World-of-Silicates.pptx
swethasejal123
 
VisionIAS - UPSC GS Paper I Question Paper 2025 with Answer Key.pdf
saxenashubh937
 
Why Agentops requires an artificial Intelligence developer.pdf
ssiddhant550
 
21st-Literature.pptxjsududhshsusushshsusuhsgsysh
JohnVJLBellen
 
Formwalaa: Your One-Stop Hub for Exam & Job Application Forms
Reeshna Prajeesh
 
Web Developer Jobs in Jaipur Your Gateway to a Thriving Tech Career in Rajast...
vinay salarite
 
Jimmy Swaggart:Rise,Fall,and Rédemption.
Jimmy carter
 
Jai resume COME WAY FOR KNOWLEDGE IN THE.pdf
kunal946067
 
Canopy Manipulation For Optimum Utilization of Light.pptx
vishalpatidar74
 
PMCF (Performance Monitoring and Coaching Form
ROSALIESOMBILON
 
100%复刻西班牙学历认证范本科尔多瓦大学成绩单防伪UCO学费单
Taqyea
 
Learn AI in Software Testing - Venkatesh (Rahul Shetty)
Venkatesh (Rahul Shetty)
 
Mastering the Cloud with AWS: A Deep Dive into Amazon Web Services
cbitssnavjotdm
 
NotificationForTheTeachingPositionsAdvt012025.pdf
sunitsaathi
 
Ganesh Mahajan Digital marketing Portfolio.pptx
ganeshmahajan786
 
Stefano_Zorzi_Curriculum_short_english.pdf
stefanogeomzorzi
 

37 Java Interview Questions

  • 2. What is the difference between String, StringBuffer, and StringBuilder in Java? Question 1:
  • 3. How do you run a Java application on the command line and set the classpath with multiple jars? Question 2:
  • 4. What is the difference between final, finalize, and finally? Question 3:
  • 5. How does Garbage Collection prevent a Java application from going out of memory? Question 4:
  • 6. What is the difference between a ClassNotFoundException a n d NoClassDefFoundError? Question 5:
  • 7. Why isn't String's .length() accurate? Question 6:
  • 8. Given two double values d1, d2, why isn’t it reliable to test their equality using:
 Question 7: d1 == d2
  • 9. What is the problem with this code: Question 8: final byte[] bytes = someString.getBytes();
  • 10. What is the JIT? Question 9:
  • 11. final double d = 1 / 2; System.out.println(d); Question 10: Why does Print 0? How can you make the code print 0.5 instead?
  • 12. IntStream.range(0, 10).forEach(System.out::println); Question 11: In this code: what is the inferred type of the method reference System.out::println?
  • 13. final Path path = Paths.get(...); Files.lines(path).forEach(System.out::println); Question 12: What is the problem with this code:
  • 14. What will be the contents of the list after this operation and why? Question 13: final List<Integer> list = new ArrayList<>(); list.add(1); list.add(2); list.add(3); list.remove(2);
  • 15. Write a function to detect if two strings are anagrams (for example, SAVE and VASE) Question 14:
  • 16. What is the contract between equals and hashCode of an object? Question 15:
  • 17. Can an enum be extended? Question 16:
  • 18. How threadsafe is enum in Java? Question 17:
  • 19. How does a JVM handle storing local variables vs storing objects? Question 18:
  • 20. Identify the problem in the following code: Question 19: public class Foo { public Foo() { doSomething(); } public void doSomething() { System.out.println("do something acceptable"); } } public class Bar extends Foo { public void doSomething() { System.out.println("yolo"); Zoom zoom = new Zoom(this); } }
  • 21. When do you use volatile variables? Question 20:
  • 22. Why do you need to use synchronized methods or blocks? Question 21:
  • 23. What is the difference between HashMap and ConcurrentHashMap? Question 22:
  • 24. When do you need to override the equals and hashCode methods in Java? Question 23:
  • 25. What is a service? Question 24:
  • 26. What is a good usecase of calling System.gc()? Question 25:
  • 27. What is the marker interface in Java? Question 26:
  • 28. How are Annotations better than a Marker Interfaces? Question 27:
  • 29. What are checked and unchecked exceptions? When do you use them? Question 28:
  • 30. int a = 1L; Won’t compile and int b = 0; b += 1L; compiles fine. Why ? Question 29:
  • 31. Why aren’t you allowed to extend more than one class in Java but are allowed to implement multiple interfaces? Question 30:
  • 32. Question 31: Test t = null; t.someMethod(); public static void someMethod() { ... } Why doesn’t the following code generate a NullPointerException even when the instance is null?
  • 33. Question 32: public class Test { public static void main(String[] args) { Integer a = 1000, b = 1000; System.out.println(a == b); Integer c = 100, d = 100; System.out.println(c == d); } } why does the first case print false while the second case prints true?
  • 34. Question 33: String s1="home"; String s2="mohe"; How do you check whether or not the following two strings are anagrams?
  • 35. How do you reverse String("Java Programming") without using Iterations and Recursions? Question 34:
  • 36. Give real world examples of when to use an ArrayList and when to use LinkedList Question 35:
  • 37. What is the difference between an Iterator and a ListIterator? Question 36:
  • 38. What is the advantage of a generic collection? Question 37:
  • 39. Did you know how to answer all 37 questions? Feel free to check your answers here or schedule a mock interview with an experienced Java developer