Published on

Java Fundamentals

Authors
Time yourself:
Your progress:

00:30:00

0%

Language Basics

1. How do you make a class Immutable in java? How about pass by reference issue?

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

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?

Flag important question
Mark as complete

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

Flag important question
Mark as complete

6. What is the difference between == and equals() in Java?

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

10. What Is a ClassLoader?

Flag important question
Mark as complete

11. What Is the purpose of the Serializable interface?

Flag important question
Mark as complete

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

Flag important question
Mark as complete

Strings and Text Processing

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

Flag important question
Mark as complete

14. Reverse a String without using any library method

Flag important question
Mark as complete

15. Validate an Email Address using Pattern and Matcher

Flag important question
Mark as complete

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

Flag important question
Mark as complete

Exceptions and Errors Handling

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

Generics and Type Safety

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

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

Flag important question
Mark as complete

Memory Management

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

Pro Content

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

Pro Content

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

Pro Content

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

Pro Content

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

Pro Content

34. How can you use WeakHashMap for Automatic Cleanup?

Pro Content

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

Pro Content

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

Pro Content

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

Pro Content

Functional Programming

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

Pro Content

39. How do Predicate and Function differ in Java?

Pro Content

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

Pro Content

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

Pro Content

Date and Time API

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

Pro Content

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

Pro Content

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

Pro Content

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

Pro Content

Reflection and Annotations

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

Pro Content

47. What are the different retention policies for annotations?

Pro Content

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

Pro Content

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?

Pro Content

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

Pro Content

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

Pro Content

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

Pro Content

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

Pro Content

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

Pro Content

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

Pro Content