- Published:
- Last updated:
Java Fundamentals
- Authors
- Name
- Lucian Oprea
- @LucianDSA_
00:30:00
Language Basics
Filter by difficulty
55 of 55 questions shown
⏷ 1. How do you make a class Immutable in java? How about pass by reference issue?
⏷ 2. What is the importance of hashCode() and equals() methods?
⏷ 3. Is Data Passed by Reference or by Value in Java?
⏷ 4. Nested classes can be static or non-static (Inner Class). How do you decide which to use? Does it matter?
⏷ 5. What are static initializers and when would you use them?
Free preview complete
You’ve reached the end of the free preview
Get every remaining question and complete answer, plus progress tracking across the full Interview Question Library.
- 50 more questions and complete answers in this topic
- Full access to every interview topic
- Progress tracking and question flags
- New questions and improvements during your subscription
Full access from
$12/month
No long-term commitment. Cancel whenever you want.
⏷ 6. What is the difference between == and equals() in Java?
⏷ 7. What happens if you assign a long to an int? How would you handle such a situation in Java?
⏷ 8. What’s the difference between a checked and unchecked exception? Can you explain with examples of each?
⏷ 9. What is the difference between the Comparable and Comparator interfaces
⏷ 10. What Is a ClassLoader?
⏷ 11. What Is the purpose of the Serializable interface?
⏷ 12. What happens if there is no break in a switch statement?
Strings and Text Processing
⏷ 13. Why are Strings immutable in Java, and when would you prefer StringBuilder over String?
⏷ 14. Reverse a String without using any library method
⏷ 15. Validate an Email Address using Pattern and Matcher
⏷ 16. How would you read a file line by line in Java?
Exceptions and Errors Handling
⏷ 17. What happens if there is a return statement in the try block and the finally block?
⏷ 18. What is the difference between Exception and Error in Java?
⏷ 19. Can you explain the hierarchy of exceptions in Java?
⏷ 20. What happens if an Exception is thrown in a static block?
⏷ 21. How do you create a Custom Exception in Java? When it’s useful?
⏷ 22. What are best practices for exception handling in Java?
⏷ 23. What is a NullPointerException, and how can you prevent it?
⏷ 24. How do you handle exceptions in a multi-threaded environment?
Generics and Type Safety
⏷ 25. What is the difference between ? extends and ? super in generics?
⏷ 26. How do you create a generic method in Java?
⏷ 27. Can you explain the purpose of the T, E, K, and V placeholders in generics?
⏷ 28. Write a program to create a generic class for a simple stack implementation.
Memory Management
⏷ 29. What is the Java memory model, and how is memory divided in the JVM?
⏷ 30. What is the difference between stack memory and heap memory?
⏷ 31. What is garbage collection in Java, and why is it important?
⏷ 32. What is a memory leak in Java, and how can it occur despite garbage collection?
⏷ 33. To avoid memory leaks why is best practice to avoid unnecessary static references.
⏷ 34. How can you use WeakHashMap for Automatic Cleanup?
⏷ 35. What are OutOfMemoryError and StackOverflowError, and how do you handle them?
⏷ 36. What is the purpose of the finalize() method, and why is it discouraged?
⏷ 37. What tools or techniques can you use to analyze and optimize memory usage in Java?
Functional Programming
⏷ 38. What is the purpose of the @FunctionalInterface annotation?
⏷ 39. How do Predicate and Function differ in Java?
⏷ 40. How can you use method references to simplify code with lambda expressions?
⏷ 41. What is the purpose of the Optional class? Provide multiple examples.
Date and Time API
⏷ 42. What are the main differences between Date and LocalDate in Java?
⏷ 43. How do you format a LocalDateTime object to a specific pattern?
⏷ 44. How do you calculate the difference between two dates in Java 8?
⏷ 45. How do you convert a legacy Date object to a LocalDate?
Reflection and Annotations
⏷ 46. What is Reflection? Give an example of functionality that can only be implemented using reflection.
⏷ 47. What are the different retention policies for annotations?
⏷ 48. How do you create a custom annotation in Java?
New features in Java 11 & Java 17
⏷ 49. What are the new String methods introduced in Java 11, and how do they differ from Java 8?
⏷ 50. What is the purpose of the var keyword introduced in Java 10, and is it available in Java 8?
⏷ 51. How does the new HTTP Client API in Java 11 improve over the HTTP libraries used in Java 8?
⏷ 52. What new features in sealed classes introduced in Java 17 make them different from regular inheritance models in Java 11?
⏷ 53. What are the improvements in pattern matching in Java 17 compared to Java 11?
⏷ 54. How does Java 17 improve text blocks compared to Java 11?
⏷ 55. What are records, and how do they differ from regular Java classes?