Core Java Basics
- What is Java, and what are its key features?
- What is the difference between JDK, JRE, and JVM?
- What is the purpose of the main method in Java?
- What are the different data types in Java?
- What is the difference between primitive and non-primitive data types?
- What is a variable in Java, and how do you declare it?
- What is type casting in Java? Explain implicit and explicit casting.
- What are the access modifiers in Java?
- What is the difference between public, private, protected, and default access modifiers?
- What is the significance of the static keyword in Java?
- What is the difference between final, finally, and finalize?
- What is the purpose of the this keyword in Java?
- What is the super keyword used for in Java?
- What is a constructor in Java?
- What is the difference between default and parameterized constructors?
- Can a constructor be private in Java?
- What is constructor overloading?
- What is the difference between a local variable and an instance variable?
- What is a static variable, and when is it used?
- What is the role of the System.out.println method?
- What is the difference between == and equals() in Java?
- What is the toString() method in Java?
- What is the purpose of the hashCode() method?
- What is the difference between String, StringBuilder, and StringBuffer?
- Why is String immutable in Java?
- What is a wrapper class in Java?
- What is autoboxing and unboxing in Java?
- What is the difference between int and Integer in Java?
- What is the purpose of the var keyword introduced in Java 10?
- What is the difference between a class and an object in Java?
Object-Oriented Programming (OOP)
- What are the four pillars of OOP in Java?
- What is encapsulation, and how is it achieved in Java?
- What is inheritance, and how does Java support it?
- What is the difference between single and multiple inheritance in Java?
- Why doesn’t Java support multiple inheritance for classes?
- What is polymorphism in Java?
- What is the difference between method overloading and method overriding?
- What is an abstract class in Java?
- Can an abstract class have a constructor?
- What is an interface in Java?
- What is the difference between an abstract class and an interface?
- Can an interface have instance variables?
- What are default methods in Java interfaces (introduced in Java 8)?
- What is a marker interface in Java?
- What is the implements keyword used for?
- What is the extends keyword used for?
- What is method hiding in Java?
- What is the diamond problem in Java?
- Can a class implement multiple interfaces in Java?
- What is the purpose of the super() call in a constructor?
- What is the instanceof operator in Java?
- What is a final class, and why is it used?
- What is the difference between composition and inheritance?
- What is the Object class in Java, and why is it important?
- What is the difference between has-a and is-a relationships?
- What is method overriding with respect to covariant return types?
- Can a static method be overridden in Java?
- What is the role of the @Override annotation?
- What is abstraction in Java, and how is it achieved?
- What is the difference between compile-time and runtime polymorphism?
Java Collections Framework
- What is the Java Collections Framework?
- What is the difference between List, Set, and Map?
- What is the difference between ArrayList and LinkedList?
- What is the difference between ArrayList and Vector?
- What is the purpose of the HashMap class?
- How does HashMap handle collisions in Java?
- What is the difference between HashMap and Hashtable?
- What is a TreeMap, and how is it different from HashMap?
- What is the ConcurrentHashMap class, and when is it used?
- What is the difference between Set and List?
- What is the purpose of the Iterator interface?
- What is the difference between Iterator and ListIterator?
- What is the Comparable interface in Java?
- What is the Comparator interface, and how is it different from Comparable?
- What is the difference between HashSet and TreeSet?
- What is the purpose of the Collections class in Java?
- What is the synchronizedList method in the Collections class?
- What is a PriorityQueue in Java?
- What is the difference between fail-fast and fail-safe iterators?
- How do you sort a List in Java?
- What is the time complexity of operations in ArrayList?
- What is the time complexity of operations in HashMap?
- What is a LinkedHashMap, and how is it different from HashMap?
- What is the Deque interface in Java?
- What is the purpose of the NavigableMap interface?
- What is the difference between Queue and Deque?
- How do you convert a List to a Set in Java?
- What is the Collections.sort() method used for?
- What is the significance of the equals() and hashCode() methods in collections?
- What is the difference between Array and ArrayList?
Exception Handling
- What is an exception in Java?
- What is the difference between checked and unchecked exceptions?
- What is the purpose of the try-catch block?
- What is the finally block, and when is it executed?
- What is the throw keyword in Java?
- What is the throws keyword, and how is it used?
- What is a custom exception in Java, and how do you create one?
- What is the difference between Exception and Error in Java?
- What is the hierarchy of exceptions in Java?
- What is the purpose of the try-with-resources statement?
- Can multiple exceptions be caught in a single catch block?
- What happens if an exception is not handled in a program?
- What is the difference between final, finally, and finalize in the context of exceptions?
- What is a NullPointerException, and how can it be avoided?
- What is a StackOverflowError in Java?
- What is an OutOfMemoryError in Java?
- How do you create a chained exception in Java?
- What is the Throwable class in Java?
- Can a finally block be skipped in Java?
- What is the difference between try-catch and throws in exception handling?
Multithreading and Concurrency
- What is a thread in Java?
- What is the difference between a process and a thread?
- What are the different ways to create a thread in Java?
- What is the purpose of the Runnable interface?
- What is the difference between Thread class and Runnable interface?
- What is the start() method in Java threads?
- What is the run() method, and how is it different from start()?
- What is thread synchronization in Java?
- What is the synchronized keyword used for?
- What is a deadlock in Java, and how can it be avoided?
- What is the difference between wait() and sleep() in Java?
- What is the purpose of the notify() and notifyAll() methods?
- What is a ReentrantLock in Java?
- What is the Executor framework in Java?
- What is the ExecutorService interface?
- What is the difference between submit() and execute() in ExecutorService?
- What is a Callable interface, and how is it different from Runnable?
- What is the Future class in Java?
- What is a thread pool in Java?
- What is the volatile keyword in Java?
- What is the ThreadLocal class, and when is it used?
- What is the join() method in Java threads?
- What is the yield() method in Java threads?
- What is the interrupt() method in Java?
- What is the difference between synchronized block and synchronized method?
- What is the ConcurrentHashMap class in the context of concurrency?
- What is the CopyOnWriteArrayList class?
- What is the Semaphore class in Java?
- What is the CountDownLatch class in Java?
- What is the CyclicBarrier class in Java?
- What is the ForkJoinPool in Java?
- What is the BlockingQueue interface?
- What is the difference between ReentrantLock and synchronized?
- What is thread starvation in Java?
- What is the ThreadGroup class in Java?
- What is the Phaser class in Java?
- What is a race condition, and how can it be avoided?
- What is the AtomicInteger class in Java?
- What is the purpose of the ExecutorCompletionService class?
- What is the difference between Thread.sleep() and Thread.yield()?
Java 8 Features
- What are the new features introduced in Java 8?
- What is a lambda expression in Java?
- What is a functional interface in Java?
- What is the @FunctionalInterface annotation?
- What is the Stream API in Java 8?
- What is the difference between map() and flatMap() in streams?
- What is the Optional class in Java 8?
- How do you handle null checks using the Optional class?
- What is the forEach method in Java 8?
- What is the difference between filter() and map() in streams?
- What is the reduce() method in Java streams?
- What is the collect() method in Java streams?
- What is the Collectors class in Java 8?
- What is the purpose of the default methods in interfaces?
- What is the static method in interfaces introduced in Java 8?
- What is the Method Reference in Java 8?
- What is the difference between intermediate and terminal operations in streams?
- What is the parallelStream() method in Java 8?
- What is the LocalDate class in Java 8?
- What is the LocalTime class in Java 8?
- What is the LocalDateTime class in Java 8?
- What is the ZoneId class in Java 8?
- What is the DateTimeFormatter class in Java 8?
- What is the difference between Stream and Collection?
- How do you sort a stream in Java 8?
- What is the peek() method in Java streams?
- What is the limit() method in Java streams?
- What is the skip() method in Java streams?
- What is the anyMatch(), allMatch(), and noneMatch() methods in streams?
- What is the findFirst() and findAny() methods in Java streams?
Java Input/Output (I/O)
- What is the difference between InputStream and OutputStream?
- What is the File class in Java?
- How do you read a file in Java?
- What is the difference between FileReader and BufferedReader?
- What is the FileWriter class in Java?
- What is the purpose of the BufferedWriter class?
- What is the Serializable interface in Java?
- What is the difference between ObjectInputStream and ObjectOutputStream?
- What is the transient keyword in Java?
- What is the PrintWriter class in Java?
- How do you handle file creation in Java?
- What is the difference between byte stream and character stream?
- What is the Path class in Java NIO?
- What is the Files class in Java NIO?
- How do you copy a file using Java NIO?
- What is the RandomAccessFile class in Java?
- How do you read a file line by line in Java?
- What is the FileChannel class in Java NIO?
- What is the purpose of the Charset class in Java?
- What is the difference between FileInputStream and FileOutputStream?
Java Generics
- What are generics in Java?
- Why are generics used in Java?
- What is the <?> wildcard in Java generics?
- What is the difference between <? extends T> and <? super T>?
- What is type erasure in Java generics?
- What is a bounded type parameter in generics?
- What is an unbounded type parameter in generics?
- Can you create an array of generic types in Java?
- What is the Generic class in Java?
- What is the difference between raw types and parameterized types?
- What is the purpose of the T in generics?
- How do you create a generic method in Java?
- What is the List<?> type in Java?
- What is the difference between List<Object> and List<?>?
- What is the PECS principle in Java generics?
Java Annotations
- What are annotations in Java?
- What is the @Override annotation used for?
- What is the @Deprecated annotation in Java?
- What is the @SuppressWarnings annotation used for?
- What is the @FunctionalInterface annotation?
- How do you create a custom annotation in Java?
- What is the Retention policy in annotations?
- What is the Target meta-annotation in Java?
- What is the difference between runtime and compile-time annotations?
- What is the @Inherited annotation in Java?
Java Design Patterns
- What is a design pattern in Java?
- What is the Singleton design pattern?
- How do you implement a thread-safe Singleton in Java?
- What is the Factory design pattern?
- What is the Abstract Factory design pattern?
- What is the Builder design pattern?
- What is the Prototype design pattern?
- What is the Adapter design pattern?
- What is the Decorator design pattern?
- What is the Facade design pattern?
- What is the Observer design pattern?
- What is the Strategy design pattern?
- What is the Command design pattern?
- What is the Template Method design pattern?
- What is the Visitor design pattern?
- What is the difference between creational, structural, and behavioral design patterns?
- What is the Chain of Responsibility design pattern?
- What is the Iterator design pattern?
- What is the Mediator design pattern?
- What is the Memento design pattern?
Java Memory Management
- What is the Java Memory Model?
- What is the difference between stack and heap memory?
- What is the role of the garbage collector in Java?
- What is the finalize() method in Java?
- What is a memory leak in Java?
- What is the difference between strong, weak, soft, and phantom references?
- What is the WeakReference class in Java?
- What is the SoftReference class in Java?
- What is the PhantomReference class in Java?
- What is the System.gc() method in Java?
- What is the difference between minor and major garbage collection?
- What is the OutOfMemoryError in Java?
- How do you analyze a heap dump in Java?
- What is the jmap tool in Java?
- What is the jstack tool in Java?
Java Database Connectivity (JDBC)
- What is JDBC in Java?
- What are the steps to connect to a database using JDBC?
- What is the DriverManager class in JDBC?
- What is the Connection interface in JDBC?
- What is the Statement interface in JDBC?
- What is the PreparedStatement interface in JDBC?
- What is the CallableStatement interface in JDBC?
- What is the difference between Statement and PreparedStatement?
- What is the ResultSet interface in JDBC?
- What is a connection pool in JDBC?
- What is the DataSource interface in JDBC?
- How do you handle transactions in JDBC?
- What is the commit() method in JDBC?
- What is the rollback() method in JDBC?
- What is the Batch processing in JDBC?
- What is the RowSet interface in JDBC?
- What is the difference between TYPE_FORWARD_ONLY and TYPE_SCROLL_INSENSITIVE ResultSet?
- What is the DatabaseMetaData interface in JDBC?
- What is the ResultSetMetaData interface in JDBC?
- How do you handle SQL exceptions in JDBC?
Java Servlets and JSP
- What is a servlet in Java?
- What is the lifecycle of a servlet?
- What is the HttpServlet class in Java?
- What is the difference between doGet() and doPost() methods?
- What is the ServletConfig interface?
- What is the ServletContext interface?
- What is the difference between ServletConfig and ServletContext?
- What is a JSP (JavaServer Pages)?
- What is the difference between a servlet and a JSP?
- What are JSP directives?
- What is the page directive in JSP?
- What is the include directive in JSP?
- What is the taglib directive in JSP?
- What are JSP implicit objects?
- What is the request object in JSP?
- What is the session object in JSP?
- What is the application object in JSP?
- What is the difference between forward and redirect in servlets?
- What is a filter in Java servlets?
- What is the web.xml file in a Java web application?
Spring Framework
- What is the Spring framework?
- What is Inversion of Control (IoC) in Spring?
- What is Dependency Injection in Spring?
- What is the difference between constructor and setter injection?
- What is the ApplicationContext in Spring?
- What is the BeanFactory in Spring?
- What is the difference between ApplicationContext and BeanFactory?
- What is a Spring bean?
- What is the @Component annotation in Spring?
- What is the @Autowired annotation in Spring?
- What is the @Qualifier annotation in Spring?
- What is the @Configuration annotation in Spring?
- What is the @Bean annotation in Spring?
- What is Spring MVC?
- What is the DispatcherServlet in Spring MVC?
- What is the @Controller annotation in Spring?
- What is the @RequestMapping annotation in Spring?
- What is the @RestController annotation in Spring?
- What is the difference between @Controller and @RestController?
- What is Spring Boot?
- What is the @SpringBootApplication annotation?
- What is the purpose of the application.properties file in Spring Boot?
- What is Spring Data JPA?
- What is the @Entity annotation in Spring Data JPA?
- What is the @Repository annotation in Spring?
- What is the CrudRepository interface in Spring Data?
- What is the JpaRepository interface in Spring Data?
- What is Spring Security?
- What is the @Secured annotation in Spring Security?
- What is the @EnableWebSecurity annotation in Spring?
Hibernate
- What is Hibernate in Java?
- What is the difference between Hibernate and JDBC?
- What is the SessionFactory in Hibernate?
- What is the Session interface in Hibernate?
- What is the Transaction interface in Hibernate?
- What is the Configuration class in Hibernate?
- What is the hibernate.cfg.xml file?
- What is an entity in Hibernate?
- What is the @Entity annotation in Hibernate?
- What is the @Id annotation in Hibernate?
- What is the @GeneratedValue annotation in Hibernate?
- What is the difference between save() and persist() in Hibernate?
- What is the difference between merge() and update() in Hibernate?
- What is the Criteria API in Hibernate?
- What is HQL (Hibernate Query Language)?
- What is the difference between get() and load() in Hibernate?
- What is lazy loading in Hibernate?
- What is eager loading in Hibernate?
- What is the N+1 problem in Hibernate?
- What is the @OneToMany annotation in Hibernate?
- What is the @ManyToOne annotation in Hibernate?
- What is the @ManyToMany annotation in Hibernate?
- What is the @JoinColumn annotation in Hibernate?
- What is the CascadeType in Hibernate?
- What is the FetchType in Hibernate?
Java Testing
- What is JUnit in Java?
- What is the @Test annotation in JUnit?
- What is the @Before annotation in JUnit?
- What is the @After annotation in JUnit?
- What is the @BeforeEach annotation in JUnit 5?
- What is the @AfterEach annotation in JUnit 5?
- What is the assertEquals() method in JUnit?
- What is the assertThrows() method in JUnit?
- What is Mockito in Java?
- What is the @Mock annotation in Mockito?
- What is the @InjectMocks annotation in Mockito?
- What is the difference between @Mock and @Spy in Mockito?
- What is the when().thenReturn() method in Mockito?
- What is TestNG in Java?
- What is the @Test annotation in TestNG?
- What is the difference between JUnit and TestNG?
- What is the assertThat() method in Hamcrest?
- What is a test suite in JUnit?
- What is a parameterized test in JUnit?
- What is the @ParameterizedTest annotation in JUnit 5?
Java Performance and Optimization
- How do you optimize Java code for performance?
- What is the role of the StringBuilder class in performance optimization?
- What is the difference between StringBuilder and StringBuffer in terms of performance?
- How do you avoid memory leaks in Java?
- What is the jvisualvm tool in Java?
- What is the jprofiler tool in Java?
- What is the significance of the -Xmx and -Xms JVM options?
- What is the metaspace in Java 8 and above?
- What is the G1 garbage collector in Java?
- How do you profile a Java application?
Java Security
- What is the Java Security Manager?
- What is the SecureRandom class in Java?
- What is the difference between symmetric and asymmetric encryption in Java?
- What is the Cipher class in Java?
- What is the KeyStore class in Java?
- What is the MessageDigest class in Java?
- How do you implement password hashing in Java?
- What is the java.security package?
- What is the SSLContext class in Java?
- What is the TrustManager in Java?
Java Microservices
- What is a microservice in Java?
- What is Spring Cloud in the context of microservices?
- What is the Eureka server in Spring Cloud?
- What is the Zuul gateway in Spring Cloud?
- What is the Hystrix library in Spring Cloud?
- What is the Spring Cloud Config server?
- What is the Feign client in Spring Cloud?
- What is the Ribbon load balancer in Spring Cloud?
- What is the difference between monolithic and microservices architecture?
- What is Docker in the context of Java microservices?
Java Miscellaneous
- What is the ClassLoader in Java?
- What is the difference between ClassNotFoundException and NoClassDefFoundError?
- What is the Reflection API in Java?
- What is the Proxy class in Java?
- What is the java.util.concurrent package?
- What is the CompletableFuture class in Java?
- What is the Optional class used for in Java?
- What is the Record class introduced in Java 14?
- What is the Sealed class introduced in Java 15?
- What is the Pattern Matching feature in Java?
- What is the instanceof pattern matching in Java 14?
- What is the Text Block feature introduced in Java 13?
- What is the Switch Expression introduced in Java 12?
- What is the var keyword introduced in Java 10?
- What is the java.time package in Java 8?
Java Advanced Topics
- What is the ForkJoinPool in Java?
- What is the Stream API’s parallel processing?
- What is the VarHandle class in Java?
- What is the Module system in Java 9?
- What is the jlink tool in Java 9?
- What is the jdeps tool in Java?
- What is the java.util.function package?
- What is the Consumer interface in Java?
- What is the Supplier interface in Java?
- What is the Predicate interface in Java?
- What is the Function interface in Java?
- What is the BiFunction interface in Java?
- What is the java.util.stream package?
- What is the java.nio package?
- What is the Path interface in Java NIO?
Java Web Services
- What is a RESTful web service in Java?
- What is the difference between REST and SOAP?
- What is the @Path annotation in JAX-RS?
- What is the @GET annotation in JAX-RS?
- What is the @POST annotation in JAX-RS?
- What is the Response class in JAX-RS?
- What is the WebService annotation in JAX-WS?
- What is the WSDL file in SOAP web services?
- What is JSON in the context of Java web services?
- What is the ObjectMapper class in Jackson?
Java Logging
- What is logging in Java?
- What is the java.util.logging package?
- What is the Log4j library in Java?
- What is the SLF4J API in Java?
- What is the difference between Log4j and SLF4J?
Java Build Tools
- What is Maven in Java?
- What is the pom.xml file in Maven?
- What is Gradle in Java?
- What is the difference between Maven and Gradle?
- What is the settings.xml file in Maven?
Java Cloud and Deployment
- What is a Java application deployment?
- What is the WAR file in Java?
- What is the JAR file in Java?
- What is the difference between WAR and JAR files?
- What is the EAR file in Java?
- What is Docker in the context of Java applications?
- What is Kubernetes in the context of Java applications?
- What is the Spring Cloud for deploying microservices?
- What is the AWS SDK for Java?
- What is the Azure SDK for Java?
Java Performance Monitoring
- What is the JConsole tool in Java?
- What is the VisualVM tool in Java?
- What is the JProfiler tool in Java?
- What is the Heap Dump in Java?
- What is the Thread Dump in Java?
Java Best Practices
- What are the best practices for writing clean Java code?
- What is the significance of naming conventions in Java?
- What is the purpose of the package statement in Java?
- What is the JavaDoc tool in Java?
- What are the benefits of using try-with-resources for resource management?
Java Security Best Practices
- How do you prevent SQL injection in Java?
- How do you prevent XSS (Cross-Site Scripting) in Java?
- What is CSRF (Cross-Site Request Forgery) in Java web applications?
- How do you secure a REST API in Java?
- What is the OWASP Top 10 for Java applications?
Java Interview Coding Questions
- How do you reverse a string in Java?
- How do you find the factorial of a number in Java?
- How do you check if a string is a palindrome in Java?
- How do you find the largest element in an array in Java?
- How do you sort an array in Java without using Arrays.sort()?
- How do you implement a binary search in Java?
- How do you swap two numbers without using a third variable?
- How do you find the second largest element in an array?
- How do you check if a number is prime in Java?
- How do you find duplicates in an array in Java?
- How do you merge two sorted arrays in Java?
- How do you implement a linked list in Java?
- How do you reverse a linked list in Java?
- How do you find the middle element of a linked list?
- How do you detect a loop in a linked list?
- How do you implement a stack in Java?
- How do you implement a queue in Java?
- How do you implement a binary tree in Java?
- How do you perform an in-order traversal of a binary tree?
- How do you find the depth of a binary tree in Java?
- How do you check if two strings are anagrams in Java?
- How do you remove duplicates from a string in Java?
- How do you implement a bubble sort in Java?
- How do you implement a quicksort in Java?
- How do you find the intersection of two arrays in Java?
This list of 505 questions covers a broad spectrum of Java topics, from beginner to advanced levels, and is designed to help students thoroughly prepare for Java interviews. You can use these questions to practice and write answers manually to deepen your understanding. If you need clarification on any specific question or topic, let me know!