0% found this document useful (0 votes)
5 views5 pages

Core Java Question

The document is a comprehensive master list of topics related to Java and Object-Oriented Programming (OOP), covering fundamental concepts, core Java basics, advanced features, exception handling, collections, streams, multithreading, JVM internals, practical coding problems, and serialization. Each section includes specific questions that delve into key aspects of Java programming, such as encapsulation, polymorphism, memory management, and functional programming. This resource serves as a guide for learners and professionals seeking to deepen their understanding of Java and its applications.

Uploaded by

sumit kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Core Java Question

The document is a comprehensive master list of topics related to Java and Object-Oriented Programming (OOP), covering fundamental concepts, core Java basics, advanced features, exception handling, collections, streams, multithreading, JVM internals, practical coding problems, and serialization. Each section includes specific questions that delve into key aspects of Java programming, such as encapsulation, polymorphism, memory management, and functional programming. This resource serves as a guide for learners and professionals seeking to deepen their understanding of Java and its applications.

Uploaded by

sumit kumar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

JAVA + OOP — MASTER LIST

1. OBJECT-ORIENTED PROGRAMMING (OOP)


1.​ What are the four pillars of Object-Oriented Programming, and how are they implemented in
Java?
2.​ What is polymorphism in Java, and what is the difference between compile-time and runtime
polymorphism?
3.​ What is abstraction in Java, and how is it achieved?
4.​ What is encapsulation in Java, and why is it important?
5.​ What is the difference between abstraction and encapsulation in Java?
6.​ What are SOLID principles in object-oriented design, and can you explain each with examples?

2. CORE JAVA BASICS


7.​ What does “immutable” mean in Java, and why are Strings immutable?
8.​ Why are Strings immutable in Java beyond just security reasons?
9.​ How do you create an immutable class in Java?
10.​What is the difference between == and equals() in Java?
11.​What is the difference between primitive data types and wrapper classes in Java?
12.​What are wrapper classes in Java, and why are they needed?
13.​What are constructors in Java, and how do they work?
14.​What are the different types of constructors in Java?
15.​Can a constructor be private in Java, and in which scenarios would you use it?
16.​What are access modifiers in Java, and what is the scope of each?
17.​Why is the method signature public static void main(String[] args) used in Java?
18.​Can you run a Java program without a main method, and how?
19.​What are the main features of Java?
20.​What are the key components required to run a Java program such as JDK, JRE, and JVM?
21.​What is the Java String Pool, and how does it work internally?
22.​What is the output of Double.MIN_VALUE > 0, and why?

3. OOP + LANGUAGE DEEP DIVE


23.​What is encapsulation in Java, and can you explain it with a real-world example?
24.​Can you write a sample implementation of encapsulation using a class with private fields and
methods?
25.​How is encapsulation applied in Spring Boot applications, for example in DTOs?
26.​Which type of polymorphism does method overloading represent?
27.​What is the difference between an abstract class and an interface in Java?
28.​When should you use an interface instead of an abstract class?
29.​How are variables defined differently in interfaces compared to abstract classes?
30.​If a class implements two interfaces that contain the same default method, what will happen
and how do you resolve the conflict?
31.​Can an interface have a constructor in Java, and why or why not?
32.​Can an interface have instance variables in Java, and if not, what type of variables can it have?
33.​In an inheritance hierarchy, how is a method resolved when called using a parent reference?

4. CONSTRUCTORS & CLASS BEHAVIOR


34.​Can a constructor be declared as final, static, or abstract in Java, and why or why not?
35.​In a class that contains a static block and a constructor, what is the exact order of execution
when multiple objects are created?
36.​What happens if a static block throws an unchecked exception during class loading?

5. JAVA INTERNALS & EDGE CASES


37.​Why do two Integer objects with the value 100 return true when compared using ==, but two
Integer objects with the value 200 return false?
38.​Given String s1 = "hello", s2 = "hello", and s3 = new String("hello"), what will be the result of s1
== s2 and why?
39.​Can you give a scenario where == returns true but .equals() behaves differently?
40.​How would you compare two custom objects for content equality in Java?
41.​What is the purpose of the final keyword in Java?

6. STREAMS & FUNCTIONAL PROGRAMMING


42.​What is the difference between map() and flatMap() in Java Streams?
43.​What is a functional interface in Java, and why is the @FunctionalInterface annotation
optional?
44.​Can Java Streams be reused after a terminal operation has been executed, and why or why
not?

7. EXCEPTION HANDLING
45.​What is the difference between checked and unchecked exceptions in Java?
46.​What is the difference between final, finally, and finalize() in Java?
47.​What replaced finalize() after it was deprecated in Java 9?
48.​What is try-with-resources, and how does it work internally?
49.​What happens when both try and finally blocks contain return statements?
50.​How would you handle a method that throws multiple types of exceptions?
51.​What is the difference between throw and throws in Java?
52.​What is the difference between an Error and an Exception in Java?

8. COLLECTIONS BASICS
53.​What is the difference between an Array and an ArrayList in Java?
54.​What is the difference between ArrayList and LinkedList?
55.​What is the difference between HashMap and Hashtable?
56.​What is a PriorityQueue in Java, and how does it work internally?
57.​What happens if you add a null value to an empty HashSet, and why?

9. COLLECTIONS — DEEP DIVE


58.​How does HashMap work internally in Java, including the behavior of put() and get() methods?
59.​What is the difference between HashMap and ConcurrentHashMap?
60.​What is the difference between HashMap, LinkedHashMap, and TreeMap?
61.​How does HashMap handle collisions, especially after Java 8?
62.​Can a HashMap contain null keys and values, and how are they handled internally?
63.​Can a TreeMap have a null key, and why or why not?
64.​What is the difference between fail-fast and fail-safe iterators?
65.​Why does ArrayList throw ConcurrentModificationException during iteration?
66.​What is the difference between CopyOnWriteArrayList and ArrayList?

10. MEMORY & EXECUTION


67.​What is the difference between Heap memory and Stack memory in Java?
68.​What is the difference between a process and a thread in Java?
69.​Is Java pass-by-value or pass-by-reference, and how can you demonstrate it with an example?
70.​What is garbage collection in Java, and how does it work internally?

11. STRINGS & LANGUAGE FEATURES


71.​What is the difference between String, StringBuilder, and StringBuffer in Java?
72.​What are static variables and static methods in Java?
73.​What is the difference between static methods and instance methods in Java?
74.​What is the purpose of the this keyword in Java?
75.​What is the purpose of the super keyword in Java?
76.​What is method hiding in Java, and how is it different from method overriding?
77.​Can static methods be overridden in Java, or are they only hidden?

12. JAVA 8 FEATURES


78.​What are the major features introduced in Java 8?
79.​What are lambda expressions, and how do they simplify code?
80.​What is the difference between a lambda expression and an anonymous class?
81.​What are method references, and what are the different types?
82.​What are default methods in interfaces, and why were they introduced?
83.​Can interfaces have static methods in Java, and how are they used?
84.​What happens if a class implements two interfaces that have the same default method?

13. STREAMS — COMPLETE


85.​How do you create streams in Java using approaches such as [Link](), [Link](),
and [Link]()?
86.​How do you filter elements in a collection using the filter() method?
87.​How do you transform elements using the map() method?
88.​How do you combine filter() and map() operations in a stream pipeline?
89.​How do you find elements using methods like findFirst() and findAny()?
90.​How do you perform matching operations such as allMatch() and anyMatch()?
91.​How do you perform aggregation using methods like count() and reduce()?
92.​How do you sort elements using streams?
93.​How do you remove duplicate elements using streams?
94.​How do you flatten nested collections using flatMap()?
95.​What is a Stream pipeline, and what are its components?
96.​What is the difference between intermediate and terminal operations in streams?
97.​Why is laziness important in streams?
98.​What are short-circuit operations in streams?
99.​What is non-interference in streams?
100.​ Why should streams be stateless?
101.​ What happens when duplicate keys occur in [Link]()?
102.​ When should you use parallel streams?
103.​ How do parallel streams work internally?
104.​ Do streams always improve performance?

14. MULTITHREADING & CONCURRENCY


105.​ What are the different ways to create threads in Java?
106.​ What is ExecutorService, and why is it used?
107.​ What is the difference between Runnable and Callable?
108.​ What is the difference between synchronized and volatile?
109.​ What is the lifecycle of a thread in Java?
110.​ What happens if wait() is called outside a synchronized block?
111.​ What is a deadlock in Java, and how can you resolve it?
112.​ How do you safely share a counter across multiple threads?
113.​ What is the difference between submit() and execute() in ExecutorService?
114.​ What is lock striping, and how does it improve concurrency?
115.​ Does the volatile keyword ensure atomicity?
116.​ What is the difference between CompletableFuture and Future?
117.​ Is AtomicInteger always safe, and are there edge cases?

15. JVM & ADVANCED INTERNALS


118.​ What is a ClassLoader in Java?
119.​ What is the JVM memory structure?
120.​ What is the Java Memory Model (JMM)?
121.​ What are the different garbage collection algorithms in Java?
122.​ What is the difference between minor, major, and full garbage collection?
123.​ Can Java applications experience memory leaks despite garbage collection?
124.​ What are strong, soft, weak, and phantom references in Java?
16. PRACTICAL CODING
125.​ How do you reverse a string in Java?
126.​ How do you check if a string is a palindrome?
127.​ How do you find the first non-repeated character in a string?
128.​ How do you check if two strings are anagrams?
129.​ How do you count the occurrence of each character in a string?
130.​ How do you find the longest common prefix among an array of strings?

17. STREAMS PROBLEMS


131.​ How do you find the top K elements using Java Streams?
132.​ How do you remove duplicate elements using streams?
133.​ How do you find duplicate elements using streams?
134.​ How do you convert a list into a map using streams?
135.​ How do you group objects, such as employees by department, using streams?
136.​ How do you find the highest and second-highest salary using streams?

18. DSA
137.​ How do you find the smallest number after removing K digits from a number?
138.​ How do you find the largest palindrome substring in a string?

19. JAVA INTERNALS (SERIALIZATION)


139.​ What is the transient keyword in Java, and why is it used?
140.​ How does transient affect Java serialization?
141.​ What happens to transient fields during serialization and deserialization?
142.​ How would you verify that a transient field was not persisted after deserialization?

You might also like