30 May 2024

#CoreJava

#CoreJava

Key Concepts


Topic Sub-Topics Basic Intermediate Advanced Expert
Java Basics History, Features, JVM, JRE, JDK, Hello World, Data Types, Variables, Operators, Keywords
Control Statements if-else, switch, loops (for, while, do-while), break, continue, return
OOP Concepts Class, Object, Constructor, Inheritance, Polymorphism, Encapsulation, Abstraction, Method Overloading
String Handling String class, StringBuffer, StringBuilder, Immutable Strings, String Pool, String methods
Arrays Single-Dimensional, Multi-Dimensional, Array class methods, Copying, Searching, Sorting
Wrapper Classes Autoboxing, Unboxing, Primitive wrappers (Integer, Double, etc.)
Exception Handling try-catch, finally, throw, throws, custom exceptions, exception hierarchy
Collections Framework List, Set, Map, Queue, Iterator, Generics, Utility classes (Collections, Arrays)
Multithreading Thread class, Runnable, Synchronization, Inter-thread communication, Executors, Concurrency utilities
Java I/O Streams, Readers/Writers, File Handling, Serialization, NIO, NIO.2
Inner Classes Member, Local, Anonymous, Static nested classes
Java 8 Features Lambda Expressions, Functional Interfaces, Streams API, Optional, Default/Static methods in interfaces
Memory Management Stack vs Heap, Garbage Collection, Finalization, References (Soft, Weak, Phantom)
Java Reflection API Class object, Reflection for methods, fields, constructors, Annotations
Annotations Built-in annotations, Custom annotations, Meta-annotations, Processing annotations
JDBC Driver types, Connection, Statement, PreparedStatement, ResultSet, Transactions
Serialization Serializable interface, transient keyword, Externalizable
Java Networking Socket, ServerSocket, Datagram, URL, HttpURLConnection
Java Security Access Modifiers, Security Manager, Cryptography APIs, JAAS
JVM Internals ClassLoader, Bytecode, JIT Compiler, Memory Areas, GC algorithms, JVM tuning
Design Patterns in Java Singleton, Factory, Builder, Observer, Strategy, Proxy, DAO
Advanced Concurrency Fork/Join framework, CompletableFuture, Parallel Streams, Locks, Atomic variables
Java Modules (Java 9+) Module system, module-info.java, readability, exports, services
New Java Features (10?21) var keyword, Records, Sealed classes, Switch Expressions, Pattern Matching, Virtual Threads

Interview question

1. Java Basics

  1. What are the main features of Java?
  2. Explain the differences between JDK, JRE, and JVM.
  3. What is bytecode in Java?
  4. Why is Java platform-independent?
  5. What is the difference between a compiled and interpreted language?
  6. Explain Just-In-Time (JIT) compilation in Java.
  7. What are Java?s access modifiers?
  8. Difference between == and .equals() in Java.
  9. What is the significance of the main method?
  10. Can we have multiple main methods in a class?
  11. What is the difference between primitive types and objects?
  12. Explain variable scope in Java.
  13. What are literals in Java?
  14. Difference between static and non-static variables.
  15. Explain type casting in Java.
  16. What is a package in Java?
  17. Difference between import and static import.
  18. What is the default value of local variables?
  19. What is the difference between final, finally, and finalize?
  20. Can you overload the main method?
  21. Why is Java not a purely object-oriented language?
  22. Explain garbage collection basics in Java.
  23. Can we declare a local variable as static?
  24. What is a marker interface in Java?
  25. Why is Java called ?write once, run anywhere??

2. OOP Concepts

  1. What are the four main principles of OOP?
  2. Difference between class and object in Java.
  3. Explain constructor overloading with example.
  4. What is method overloading and method overriding?
  5. Difference between abstract class and interface.
  6. Can an abstract class have a constructor?
  7. Can interfaces have default methods?
  8. Explain multiple inheritance in Java via interfaces.
  9. What is encapsulation? Give an example.
  10. What is the significance of super keyword?
  11. Can we override static methods in Java?
  12. Explain the concept of covariant return types.
  13. Difference between this and super in Java.
  14. Can we declare a class as both abstract and final?
  15. What are anonymous classes in Java?
  16. Can constructors be inherited in Java?
  17. Difference between final, abstract, and static classes.
  18. Can an interface extend multiple interfaces?
  19. What is a functional interface?
  20. Explain polymorphism with examples.
  21. What is the difference between overloading and overriding rules?
  22. Can we have multiple constructors with different access modifiers?
  23. What is object cloning in Java?
  24. Difference between shallow copy and deep copy.
  25. How is encapsulation implemented in Java?

3. Strings & Arrays

  1. Difference between String, StringBuilder, and StringBuffer.
  2. Why are strings immutable in Java?
  3. What is the String pool in Java?
  4. Difference between == and .equals() for strings.
  5. How do you compare two strings in Java?
  6. What is substring pooling in Java?
  7. Can String be extended in Java?
  8. How do you split a String in Java?
  9. Difference between intern() and normal strings.
  10. How do you reverse a String in Java?
  11. How do you check if a string is a palindrome?
  12. Difference between length() of String and length of Array.
  13. How do you copy an array in Java?
  14. What is Arrays.asList() method used for?
  15. How do you sort an array of objects?
  16. Difference between shallow copy and deep copy in arrays.
  17. How do you search an element in an array?
  18. Difference between jagged and multidimensional arrays.
  19. Can arrays in Java be resized?
  20. Difference between Array and ArrayList.
  21. What is System.arraycopy()?
  22. What is String.join() method used for?
  23. Difference between String.valueOf() and toString().
  24. How do you convert String to int and int to String?
  25. How do you count vowels in a String?

4. Exception Handling

  1. Difference between Error and Exception in Java.
  2. Difference between checked and unchecked exceptions.
  3. What happens if an exception is not caught?
  4. Explain try, catch, finally block.
  5. Can we have multiple catch blocks for a try?
  6. Can finally block be skipped?
  7. Can we use try without catch?
  8. Difference between throw and throws.
  9. What is a custom exception? Give an example.
  10. Can constructors throw exceptions?
  11. Can you declare the main method with throws clause?
  12. Difference between NoClassDefFoundError and ClassNotFoundException.
  13. Can you rethrow an exception in Java?
  14. What is exception chaining?
  15. Can static initializers throw exceptions?
  16. What is suppressed exception in try-with-resources?
  17. Difference between FileNotFoundException and IOException.
  18. Explain exception propagation in Java.
  19. Can you catch multiple exceptions in one catch block?
  20. Can overriding methods throw exceptions?
  21. Why is exception handling important in Java?
  22. What are runtime exceptions?
  23. What is the base class of all exceptions?
  24. Can final, static, and private methods throw exceptions?
  25. Explain best practices in exception handling.

5. Collections Framework

  1. What is the difference between List, Set, and Map?
  2. Difference between ArrayList and LinkedList.
  3. Difference between HashSet and TreeSet.
  4. Difference between HashMap and Hashtable.
  5. Can we store null keys in HashMap?
  6. What is the difference between fail-fast and fail-safe iterators?
  7. What is the difference between Iterator and ListIterator?
  8. Can we use generics with collections?
  9. Difference between HashMap and ConcurrentHashMap.
  10. Explain the internal working of HashMap.
  11. How does HashSet work internally?
  12. Difference between Comparator and Comparable.
  13. Can we sort a HashMap by values?
  14. Difference between TreeMap and HashMap.
  15. What is the difference between shallow copy and deep copy in collections?
  16. What is CopyOnWriteArrayList?
  17. Difference between Vector and ArrayList.
  18. How does ConcurrentHashMap achieve thread safety?
  19. Can we make a collection immutable?
  20. What are weak collections in Java?
  21. What is EnumSet and EnumMap?
  22. Difference between LinkedHashMap and HashMap.
  23. What is PriorityQueue in Java?
  24. What are Navigable collections?
  25. Difference between Collections.synchronizedList() and CopyOnWriteArrayList.

6. Multithreading & Concurrency

  1. Difference between process and thread.
  2. How do you create a thread in Java?
  3. Difference between extending Thread and implementing Runnable.
  4. What is synchronization in Java?
  5. What is inter-thread communication?
  6. Explain wait(), notify(), and notifyAll().
  7. Difference between sleep() and wait().
  8. What are daemon threads in Java?
  9. Can we start a thread twice?
  10. What is thread starvation?
  11. Difference between synchronized method and synchronized block.
  12. What is deadlock in Java?
  13. How do you avoid deadlock?
  14. What is the difference between race condition and deadlock?
  15. Explain the Executor framework in Java.
  16. What is Callable and Future in Java?
  17. What are concurrent collections?
  18. What is a volatile keyword in Java?
  19. What is a ReentrantLock?
  20. Difference between submit() and execute() in ExecutorService.
  21. What are atomic variables?
  22. What is the ForkJoin framework?
  23. Explain CompletableFuture with example.
  24. What is ThreadLocal in Java?
  25. What are virtual threads in Java?

7. Java I/O & Serialization

  1. Difference between byte streams and character streams.
  2. What are InputStream and OutputStream?
  3. Difference between FileReader and FileInputStream.
  4. What is a BufferedReader?
  5. Difference between Scanner and BufferedReader.
  6. What is Object Serialization?
  7. What is the use of the transient keyword?
  8. Difference between Serializable and Externalizable.
  9. Can static variables be serialized?
  10. What is NIO in Java?
  11. Difference between FileChannel and Stream.
  12. What are memory-mapped files?
  13. How do you read a large file efficiently?
  14. Difference between Reader and Writer in Java.
  15. What is PrintWriter used for?
  16. What is RandomAccessFile?
  17. Difference between flush() and close().
  18. What is Path, Paths, and Files class in NIO.2?
  19. Explain WatchService API in NIO.
  20. How to copy files in Java?
  21. What is serialization proxy pattern?
  22. Difference between character encoding and decoding.
  23. What is Base64 encoding in Java?
  24. How do you compress files in Java?
  25. What are ZipInputStream and ZipOutputStream?

8. Advanced Java Features

  1. What are lambda expressions in Java?
  2. What is a functional interface?
  3. Difference between Predicate, Consumer, and Function.
  4. What is method reference in Java?
  5. What is the Optional class in Java?
  6. Difference between map() and flatMap() in Streams.
  7. What is a parallel stream?
  8. What are default and static methods in interfaces?
  9. What is the difference between filter(), map(), and reduce()?
  10. Difference between findFirst() and findAny().
  11. What is the purpose of Collectors class?
  12. What are immutable collections in Java 9?
  13. What is the var keyword in Java 10?
  14. What are records in Java?
  15. What are sealed classes in Java?
  16. What is pattern matching for instanceof?
  17. Difference between switch expressions and switch statements.
  18. What are text blocks in Java?
  19. What are virtual threads (Project Loom)?
  20. What are structured concurrency features in Java?
  21. Difference between record and class.
  22. What are string templates (Java 21)?
  23. What is the Vector API in Java?
  24. What are hidden classes in Java?
  25. What are value types (Project Valhalla)?

9. Memory Management & JVM Internals

  1. Explain stack vs heap memory in Java.
  2. What is the method area in JVM?
  3. Difference between classloader types.
  4. What are the phases of class loading?
  5. Explain the difference between bootstrap and system classloader.
  6. What is the PermGen and Metaspace in Java?
  7. What is Just-In-Time (JIT) compiler?
  8. Difference between client and server JVM.
  9. What are the different types of garbage collectors?
  10. Explain G1 garbage collector.
  11. What is garbage collection tuning?
  12. What are reference types (soft, weak, phantom)?
  13. Explain finalize() method in Java.
  14. What is escape analysis?
  15. Difference between heap dump and thread dump.
  16. What is memory leak in Java?
  17. How do you monitor JVM memory usage?
  18. What is OutOfMemoryError?
  19. What is StackOverflowError?
  20. How do you optimize Java memory usage?
  21. What is class reloading in JVM?
  22. What are JIT optimizations?
  23. Difference between Stop-the-world and Concurrent GC.
  24. What is ahead-of-time (AOT) compilation?
  25. Explain Z Garbage Collector.

10. Design Patterns & Best Practices

  1. What is the Singleton pattern? How is it implemented in Java?
  2. Explain the Factory pattern in Java.
  3. What is the Builder pattern?
  4. Explain the Prototype pattern.
  5. What is the Adapter pattern?
  6. Explain the Strategy pattern.
  7. What is the Observer pattern?
  8. Explain the Proxy pattern.
  9. What is the Decorator pattern?
  10. What is the Command pattern?
  11. Explain the DAO pattern in Java.
  12. Difference between Singleton and Static class.
  13. What is Dependency Injection in Java?
  14. What is the Template Method pattern?
  15. Explain the difference between composition and inheritance.
  16. What is the difference between DTO and VO?
  17. What is the Law of Demeter?
  18. What are SOLID principles?
  19. Explain KISS, DRY, and YAGNI principles.
  20. What is the difference between immutability and mutability?
  21. Explain fail-fast and fail-safe best practices.
  22. How do you design exception-safe APIs?
  23. What is defensive copying?
  24. What is thread-safe design?
  25. Explain best practices for Java coding standards.

Related Topics


   Java_Versions   
   OOP Concepts   
   Collections   
   Exception_Handling   
   String_Class   
   MultiThread   
   Generics   
   JDBC   
   Java_IO