Published:
Last updated:

Java Fundamentals

Authors
Time yourself:
Your progress:

00:30:00

0%

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?

Mid-level
Flag important question
Mark as complete

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

Junior
Flag important question
Mark as complete

3. Is Data Passed by Reference or by Value in Java?

Mid-level
Flag important question
Mark as complete

4. Nested classes can be static or non-static (Inner Class). How do you decide which to use? Does it matter?

Mid-level
Flag important question
Mark as complete

5. What are static initializers and when would you use them?

Junior
Flag important question
Mark as complete

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?

JuniorPaid Question

7. What happens if you assign a long to an int? How would you handle such a situation in Java?

JuniorPaid Question

8. What’s the difference between a checked and unchecked exception? Can you explain with examples of each?

Mid-levelPaid Question

9. What is the difference between the Comparable and Comparator interfaces

JuniorPaid Question

10. What Is a ClassLoader?

JuniorPaid Question

11. What Is the purpose of the Serializable interface?

JuniorPaid Question

12. What happens if there is no break in a switch statement?

JuniorPaid Question

Strings and Text Processing

13. Why are Strings immutable in Java, and when would you prefer StringBuilder over String?

Mid-levelPaid Question

14. Reverse a String without using any library method

Mid-levelPaid Question

15. Validate an Email Address using Pattern and Matcher

Mid-levelPaid Question

16. How would you read a file line by line in Java?

Mid-levelPaid Question

Exceptions and Errors Handling

17. What happens if there is a return statement in the try block and the finally block?

JuniorPaid Question

18. What is the difference between Exception and Error in Java?

Mid-levelPaid Question

19. Can you explain the hierarchy of exceptions in Java?

Mid-levelPaid Question

20. What happens if an Exception is thrown in a static block?

JuniorPaid Question

21. How do you create a Custom Exception in Java? When it’s useful?

Mid-levelPaid Question

22. What are best practices for exception handling in Java?

Mid-levelPaid Question

23. What is a NullPointerException, and how can you prevent it?

JuniorPaid Question

24. How do you handle exceptions in a multi-threaded environment?

Mid-levelPaid Question

Generics and Type Safety

25. What is the difference between ? extends and ? super in generics?

Mid-levelPaid Question

26. How do you create a generic method in Java?

Mid-levelPaid Question

27. Can you explain the purpose of the T, E, K, and V placeholders in generics?

Mid-levelPaid Question

28. Write a program to create a generic class for a simple stack implementation.

Mid-levelPaid Question

Memory Management

29. What is the Java memory model, and how is memory divided in the JVM?

Mid-levelPaid Question

30. What is the difference between stack memory and heap memory?

Mid-levelPaid Question

31. What is garbage collection in Java, and why is it important?

Mid-levelPaid Question

32. What is a memory leak in Java, and how can it occur despite garbage collection?

SeniorPaid Question

33. To avoid memory leaks why is best practice to avoid unnecessary static references.

SeniorPaid Question

34. How can you use WeakHashMap for Automatic Cleanup?

Mid-levelPaid Question

35. What are OutOfMemoryError and StackOverflowError, and how do you handle them?

Mid-levelPaid Question

36. What is the purpose of the finalize() method, and why is it discouraged?

Mid-levelPaid Question

37. What tools or techniques can you use to analyze and optimize memory usage in Java?

SeniorPaid Question

Functional Programming

38. What is the purpose of the @FunctionalInterface annotation?

JuniorPaid Question

39. How do Predicate and Function differ in Java?

Mid-levelPaid Question

40. How can you use method references to simplify code with lambda expressions?

Mid-levelPaid Question

41. What is the purpose of the Optional class? Provide multiple examples.

JuniorPaid Question

Date and Time API

42. What are the main differences between Date and LocalDate in Java?

Mid-levelPaid Question

43. How do you format a LocalDateTime object to a specific pattern?

Mid-levelPaid Question

44. How do you calculate the difference between two dates in Java 8?

Mid-levelPaid Question

45. How do you convert a legacy Date object to a LocalDate?

Mid-levelPaid Question

Reflection and Annotations

46. What is Reflection? Give an example of functionality that can only be implemented using reflection.

Mid-levelPaid Question

47. What are the different retention policies for annotations?

JuniorPaid Question

48. How do you create a custom annotation in Java?

Mid-levelPaid Question

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?

Mid-levelPaid Question

50. What is the purpose of the var keyword introduced in Java 10, and is it available in Java 8?

JuniorPaid Question

51. How does the new HTTP Client API in Java 11 improve over the HTTP libraries used in Java 8?

Mid-levelPaid Question

52. What new features in sealed classes introduced in Java 17 make them different from regular inheritance models in Java 11?

Mid-levelPaid Question

53. What are the improvements in pattern matching in Java 17 compared to Java 11?

JuniorPaid Question

54. How does Java 17 improve text blocks compared to Java 11?

Mid-levelPaid Question

55. What are records, and how do they differ from regular Java classes?

Mid-levelPaid Question