FullStackFSCCafé
 
 
Sign in with GoogleSign in with Google. Opens in new tab
Kill Your Tech Interview
3877 Full-Stack, Algorithms & System Design Interview Questions
Answered To Get Your Next Six-Figure Job Offer
      
🤖 Having Machine Learning & DS Interview? Check  MLStack.Cafe - 1704 Data Science & ML Interview Questions & Answers!Having ML & DS Interview? Check 🤖 MLStack.Cafe - 1704 ML & DS Interview Questions and Answers

Top 165 Java Interview Questions

Entry Junior Mid Senior Expert
Sign in with GoogleSign in with Google. Opens in new tab
Topic Progress:

Theoretical Questions

Q1:   

What is JVM? Why is Java called the "Platform Independent Programming Language”?

  
Add to PDF   Entry 
Q2:   

What is the difference between an Applet and a Java Application?

  
Add to PDF   Entry 
Q3:   

What are the two types of Exceptions in Java? Which are the differences between them?

  
Add to PDF   Entry 
Q4:   

What is a JSP Page?

  
Add to PDF   Entry 
Q5:   

What is a Servlet?

  
Add to PDF   Entry 
Q6:   

What is the Difference between JDK and JRE?

  
Add to PDF   Entry 
Q7:   

What is an Iterator?

  
Add to PDF   Junior 
Q8:   

What are the Data Types supported by Java? What is Autoboxing and Unboxing?

  
Add to PDF   Junior 
Q9:   

What are the basic interfaces of Java Collections Framework?

  
Add to PDF   Junior 
Q10:   

How HashMap works in Java?

  
Add to PDF   Junior 
Q11:   

What is an Java Applet?

  
Add to PDF   Junior 
Q12:   

What are pass by reference and pass by value?

  
Add to PDF   Junior 
Q13:   

What is the difference between processes and threads?

  
Add to PDF   Junior 
Q14:   

When does an Object becomes eligible for Garbage Collection in Java ?

  
Add to PDF   Junior 
Q15:   

What is the difference between Exception and Error in Java?

  
Add to PDF   Junior 
Q16:   

What is the importance of finally block in exception handling?

  
Add to PDF   Junior 
Q17:   

What does the static keyword mean? Can you override private or static method in Java?

  
Add to PDF   Junior 
Q18:   

What is JDBC?

  
Add to PDF   Junior 
Q19:   

What is the purpose of Garbage Collection in Java, and when is it used?

  
Add to PDF   Junior 
Q20:   

How does Garbage Collection prevent a Java application from going out of memory?

  
Add to PDF   Junior 
Q21:   

Explain Serialization and Deserialization.

  
Add to PDF   Junior 
Q22:   

Explain the architechure of a Servlet.

  
Add to PDF   Junior 
Q23:   

What is reflection and why is it useful?

  
Add to PDF   Junior 
Q24:   

What are JSP Actions?

  
Add to PDF   Junior 
Q25:   

What are Decalarations?

  
Add to PDF   Junior 
Q26:   

What’s the difference between sendRedirect and forward methods?

  
Add to PDF   Junior 
Q27:   

What is the purpose Class.forName method?

  
Add to PDF   Junior 
Q28:   

What is the design pattern that Java uses for all Swing components?

  
Add to PDF   Junior 
Q29:   

How are the JSP requests handled?

  
Add to PDF   Junior 
Q30:   

What is Function Overriding and Overloading in Java?

  
Add to PDF   Junior 
Q31:   

What do you know about the Big-O notation and can you give some examples with respect to different data structures?

  
Add to PDF   Junior 
Q32:   

What are Expressions?

  
Add to PDF   Junior 
Q33:   

What is the difference between an Interface and an Abstract class?

  
Add to PDF   Junior 
Q34:   

What will happen to the Exception object after exception handling?

  
Add to PDF   Junior 
Q35:   

Explain what is Binary Search

 JSJavaPY Related To: Searching, JavaScript
Add to PDF   Junior 
Q36:   

What are Directives?

  
Add to PDF   Junior 
Q37:   

What differences exist between HashMap and Hashtable?

  
Add to PDF   Junior 
Q38:   

What does System.gc() and Runtime.gc() methods do?

  
Add to PDF   Junior 
Q39:   

What is difference between fail-fast and fail-safe?

  
 Add to PDF   Mid 
Q40:   

Compare the sleep() and wait() methods in Java

  
 Add to PDF   Mid 
Q41:   

Is there anything like static class in Java?

  
 Add to PDF   Mid 
Q42:   

What are the differences between == and equals?

  
 Add to PDF   Mid 
Q43:   

How threadsafe is enum in Java?

  
 Add to PDF   Mid 
Q44:   

What is meant by JSP implicit objects and what are they?

  
 Add to PDF   Mid 
Q45:   

What is the advantage of PreparedStatement over Statement?

  
 Add to PDF   Mid 
Q46:   

What is difference between Array and ArrayList? When will you use Array over ArrayList?

  
 Add to PDF   Mid 
Q47:   

What is the main difference between StringBuffer and StringBuilder?

  
 Add to PDF   Mid 
Q48:   

What is Java Priority Queue?

  
 Add to PDF   Mid 
Q49:   

Explain different ways of creating a thread. Which one would you prefer and why?

  
 Add to PDF   Mid 
Q50:   

What is the importance of hashCode() and equals() methods?

  
 Add to PDF   Mid 
Q51:   

What is the volatile keyword useful for?

  
 Add to PDF   Mid 
Q52:   

Can == be used on enum?

  
 Add to PDF   Mid 
Q53:   

What do the ... dots in the method parameters mean?

  
 Add to PDF   Mid 
Q54:   

Why does Java have transient fields?

  
 Add to PDF   Mid 
Q55:   

Is Java pass-by-reference or pass-by-value?

  
 Add to PDF   Mid 
Q56:   

What is static initializer?

  
 Add to PDF   Mid 
Q57:   

What's the advantage of using getters and setters?

  
 Add to PDF   Mid 
Q58:   

What is the difference between public, protected, package-private and private in Java?

  
 Add to PDF   Mid 
Q59:   

What is the difference between HashMap, LinkedHashMap and TreeMap in Java?

  
 Add to PDF   Mid 
Q60:   

How and where are Annotations used in Java?

  
 Add to PDF   Mid 
Q61:   

What is the Java Classloader?

  
 Add to PDF   Mid 
Q62:   

Can an enum be extended?

  
 Add to PDF   Mid 
Q63:   

What is a JavaBean exactly?

  
 Add to PDF   Mid 
Q64:   

What is the JIT?

  
 Add to PDF   Mid 
Q65:   

What are the advantages of JSP?

  
 Add to PDF   Mid 
Q66:   

How do I break out of nested loops in Java?

  
 Add to PDF   Mid 
Q67:   

How can I synchornize two Java processes?

  
 Add to PDF   Mid 
Q68:   

What’s the difference between a ClassNotFoundException and NoClassDefFoundError?

  
 Add to PDF   Mid 
Q69:   

Can you access non static variable in static context?

  
 Add to PDF   Mid 
Q70:   

What is the difference between final, finalize and finally?

  
 Add to PDF   Mid 
Q71:   

What are the restrictions imposed on Java applets?

  
 Add to PDF   Mid 
Q72:   

What is the role of stub in RMI?

  
 Add to PDF   Mid 
Q73:   

What is the difference between GenericServlet and HttpServlet?

  
 Add to PDF   Mid 
Q74:   

What are Scriptlets?

  
 Add to PDF   Mid 
Q75:   

Explain the life cycle of an Applet.

  
 Add to PDF   Mid 
Q76:   

Explain the life cycle of a Servlet.

  
 Add to PDF   Mid 
Q77:   

Which Swing methods are thread-safe?

  
 Add to PDF   Mid 
Q78:   

What’s a deadlock?

  
 Add to PDF   Mid 
Q79:   

What is the tradeoff between using an unordered array versus an ordered array?

  
 Add to PDF   Mid 
Q80:   

What is the difference between doGet() and doPost()?

  
 Add to PDF   Mid 
Q81:   

What is structure of Java Heap?

  
 Add to PDF   Mid 
Q82:   

What differences exist between Iterator and ListIterator?

  
 Add to PDF   Mid 
Q83:   

How does finally block differ from finalize() method?

  
 Add to PDF   Mid 
Q84:   

Explain the role of Driver in JDBC.

  
 Add to PDF   Mid 
Q85:   

What is the difference between throw and throws?

  
 Add to PDF   Mid 
Q86:   

What is Comparable and Comparator interface? List their differences.

  
 Add to PDF   Mid 
Q87:   

What are untrusted applets?

  
 Add to PDF   Mid 
Q88:   

What is difference between ArrayList and LinkedList?

  
 Add to PDF   Mid 
Q89:   

What is the difference between an Applet and a Servlet?

  
 Add to PDF   Mid 
Q90:   

What are the steps involved to make work a RMI program?

  
 Add to PDF   Mid 
Q91:   

Why Collection doesn’t extend Cloneable and Serializable interfaces?

  
 Add to PDF   Mid 
Q92:   

If an object reference is set to null, will the Garbage Collector immediately free the memory held by that object?

  
 Add to PDF   Mid 
Q93:   

What is a Constructor, Constructor Overloading and Copy-Constructor in Java ?

  
 Add to PDF   Mid 
Q94:   

What’s the difference between Enumeration and Iterator interfaces?

  
 Add to PDF   Mid 
Q95:   

What is a Server Side Include (SSI)?

  
 Add to PDF   Mid 
Q96:   

Does Java support multiple inheritance?

  
 Add to PDF   Mid 
Q97:   

What is the relationship between an event-listener interface and an event-adapter class?

  
 Add to PDF   Mid 
Q98:   

What is the applet security manager, and what does it provide?

  
 Add to PDF   Mid 
Q99:   

What happens when an Applet is loaded?

  
 Add to PDF   Mid 
Q100:   

When is the finalize() called? What is the purpose of finalization?

  
 Add to PDF   Mid 
Q101:   

What are some of the best practices relating to the Java Collection Framework?

  
 Add to PDF   Senior 
Q102:   

Why is char[] preferred over String for passwords?

  
 Add to PDF   Senior 
Q103:   

What are the differences between a HashMap and a HashTable in Java?

  
 Add to PDF   Senior 
Q104:   

What exactly is marker interface in Java?

  
 Add to PDF   Senior 
Q105:   

When to use LinkedList over ArrayList in Java?

  
 Add to PDF   Senior 
Q106:   

Why is Spring MVC better than Servlets / JSP ?

  
 Add to PDF   Senior 
Q107:   

Explain a use case for the Builder Design Pattern

  
 Add to PDF   Senior 
Q108:   

What is the difference between Applets loaded over the internet and Applets loaded via the file system?

  
 Add to PDF   Senior 
Q109:   

How do you ensure that N threads can access N resources without deadlock?

  
 Add to PDF   Senior 
Q110:   

Does Java support default parameter values?

  
 Add to PDF   Senior 
Q111:   

What is the purpose of using RMISecurityManager in RMI?

  
 Add to PDF   Senior 
Q112:   

What is the role of the java.rmi.Naming Class?

  
 Add to PDF   Senior 
Q113:   

What is the main difference between an inner class and a static nested class in Java?

  
 Add to PDF   Senior 
Q114:   

Are there any differences between Protocol in Swift vs Interface in Java?

  Related To: Swift
 Add to PDF   Senior 
Q115:   

Explain Boyer-Moore Algorithm with Example

 Java Related To: Strings
 Add to PDF   Senior 
Q116:   

What is Servlet Chaining?

  
 Add to PDF   Senior 
Q117:   

What is the basic principle of RMI architecture?

  
 Add to PDF   Senior 
Q118:   

What does Connection Pooling mean?

  
 Add to PDF   Senior 
Q119:   

What is meant by binding in RMI?

  
 Add to PDF   Senior 
Q120:   

How do you find out what client machine is making a request to your servlet?

  
 Add to PDF   Senior 
Q121:   

Explain Marshalling and Demarshalling.

  
 Add to PDF   Senior 
Q122:   

What is the applet class loader, and what does it provide?

  
 Add to PDF   Senior 
Q123:   

What is the difference between a synchronized method and a synchronized block?

  
 Add to PDF   Senior 
Q124:   

What is Double Brace initialization in Java?

  
 Add to PDF   Senior 
Q125:   

How do I test a private function or a class that has private methods, fields or inner classes?

  
 Add to PDF   Senior 
Q126:   

What is Perm Gen space in Heap?

  
 Add to PDF   Senior 
Q127:   

What is the difference between Serial and Throughput Garbage collector?

  
 Add to PDF   Senior 
Q128:   

Explain the available thread states in a high-level.

  
 Add to PDF   Senior 
Q129:   

What is the role of Remote Interface in RMI?

  
 Add to PDF   Senior 
Q130:   

What is RMI?

  
 Add to PDF   Senior 
Q131:   

Does Garbage collection occur in permanent generation space in JVM?

  
 Add to PDF   Expert 
Q132:   

What does synchronized mean?

  
 Add to PDF   Expert 
Q133:   

What are the layers of RMI Architecture?

  
 Add to PDF   Expert 
Q134:   

What is DGC? And how does it work?

  
 Add to PDF   Expert 
Q135:   

What is the difference between HashSet and TreeSet?

  
 Add to PDF   Expert 
Q136:   

What's wrong with Double Brace Initialization in Java?

  
 Add to PDF   Expert 
Q137:   

How does thread synchronization occurs inside a monitor? What levels of synchronization can you apply?

  
 Add to PDF   Expert 
Q138:   

Why isn’t String‘s length() accurate?

  
 Add to PDF   Expert 
Q139:   

Provide some examples when a finally block won't be executed in Java?

  
 Add to PDF   Expert 
Q140:   

Compare volatile vs static variables in Java

  
 Add to PDF   Expert 
Q141:   

Why ArrayList are preferable in many more use-cases than LinkedList?

  
 Add to PDF   Expert 
Q142:   

What's the difference between SoftReference and WeakReference in Java?

  
 Add to PDF   Expert 
Q143:   

What is an efficient way to implement a singleton pattern in Java?

  
 Add to PDF   Expert 

Code Challenges

Q1:   

How do I efficiently iterate over each entry in a Java Map?

  
 Add to PDF   Junior 
Q2:   

Return the N-th value of the Fibonacci sequence Recursively

 JSJavaPY Related To: Fibonacci Series, Data Structures, JavaScript
 Add to PDF   Junior 
Q3:   

Implement a Queue using two Stacks

 CSJSJavaPY Related To: Queues, Stacks, C#, JavaScript
 Add to PDF   Junior 
Q4:   

Design a Stack that supports retrieving the min element in O(1)

 JavaPY Related To: Stacks
 Add to PDF   Junior 
Q5:   

How to reverse a singly Linked List using only two pointers?

 Java Related To: Linked Lists
 Add to PDF   Junior 
Q6:   

How to merge two sorted Arrays into a Sorted Array?

 JSJavaPY Related To: Arrays, Data Structures, JavaScript, Python
  Add to PDF   Mid 
Q7:   

How to check if two Strings (words) are Anagrams?

 CSJavaPY Related To: Strings, Data Structures, C#
  Add to PDF   Mid 
Q8:   

Write a program for Recursive Binary Search

 JSJavaPY Related To: Searching, Python, JavaScript
  Add to PDF   Mid 
Q9:   

Find all the Permutations of a String

 JSJavaPY Related To: Backtracking, Strings, Data Structures, Python, JavaScript
  Add to PDF   Mid 
Q10:   

Check if parentheses are balanced using Stack

 JSJavaPY Related To: Stacks, Python, JavaScript
  Add to PDF   Mid 
Q11:   

Sort a Stack using Recursion

 JavaPY Related To: Sorting, Stacks
  Add to PDF   Mid 
Q12:   

How do I read/convert an InputStream into a String in Java?

  
  Add to PDF   Mid 
Q13:   

Floyd's Cycle Detect Algorithm: Explain how to find a starting node of a Cycle in a Linked List?

 Java Related To: Linked Lists
  Add to PDF   Mid 
Q14:   

What is the use of CallableStatement? Name the method, which is used to prepare a CallableStatement.

  
  Add to PDF   Mid 
Q15:   

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

  
  Add to PDF   Senior 
Q16:   

Given two double values d1, d2, what is the most reliable way to test their equality?

  
  Add to PDF   Senior 
Q17:   

Build a Binary Expression Tree for this expression

 Java Related To: Binary Tree, Stacks
  Add to PDF   Senior 
Q18:   

Is null check needed before calling instanceof?

  
  Add to PDF   Senior 
Q19:   

Get Fibonacci Number in O(log n) time using Matrix Exponentiation

 JavaPY Related To: Fibonacci Series, Matrices
  Add to PDF   Senior 
Q20:   

Given a singly Linked List, determine if it is a Palindrome

 JavaPY Related To: Linked Lists, Python
  Add to PDF   Senior 
Q21:   

What is Morris Traversal for a Tree and how to implement one?

 Java Related To: Binary Tree
  Add to PDF   Expert 
Q22:   

Explain what will the code return

  
  Add to PDF   Expert 
 

Rust has been Stack Overflow’s most loved language for four years in a row and emerged as a compelling language choice for both backend and system developers, offering a unique combination of memory safety, performance, concurrency without Data races...

Clean Architecture provides a clear and modular structure for building software systems, separating business rules from implementation details. It promotes maintainability by allowing for easier updates and changes to specific components without affe...

Azure Service Bus is a crucial component for Azure cloud developers as it provides reliable and scalable messaging capabilities. It enables decoupled communication between different components of a distributed system, promoting flexibility and resili...

Cosmos DB has gained popularity among developers and organizations across various industries, including finance, e-commerce, gaming, IoT, and more. Follow along and learn the 24 most common and advanced Azure Cosmos DB interview questions and answers...
More than any other NoSQL database, and dramatically more than any relational database, MongoDB's document-oriented data model makes it exceptionally easy to add or change fields, among other things. It unlocks Iteration on the project. Iteration f...
Unit Tests and Test Driven Development (TDD) help you really understand the design of the code you are working on. Instead of writing code to do something, you are starting by outlining all the conditions you are subjecting the code to and what outpu...
Domain-Driven Design is nothing magical but it is crucial to understand the importance of Ubiquitous Language, Domain Modeling, Context Mapping, extracting the Bounded Contexts correctly, designing efficient Aggregates and etc. before your next DDD p...
At its core, Microsoft Azure is a public cloud computing platform - with solutions including Infrastructure as a Service (IaaS), Platform as a Service (PaaS), and Software as a Service (SaaS) that can be used for services such as analytics, virtual c...
As an asynchronous event-driven JavaScript runtime, Node.js is designed to build scalable network applications. Follow along to refresh your knowledge and explore the 52 most frequently asked and advanced Node JS Interview Questions and Answers every...
Dependency Injection is most useful when you're aiming for code reuse, versatility and robustness to changes in your problem domain. DI is also useful for decoupling your system. DI also allows easier unit testing without having to hit a database and...