Complete List of Java Interview Questions

If you have questions which are not listed below, send those at facilitator.zerotoherojava@gmail.com

Master Index

  1. OOPs
  2. String Handling
  3. Exception Handling
  4. Serialization
  5. Garbage Collection
  6. Multithreading
  7. Inner Class
  8. I/O
  9. Networking
  10. Generics
  11. Collection Framework
  12. Reflection
  13. JDBC
  14. Servlets
  15. New Features in JDK versions
  16. Java Coding Interview Questions

 

Object Oriented Programming (OOPs)

  1. What is OOPs?
  2. What are the advantages/benefits of OOPs
  3. What is the difference between procedural programming and OOPs?
  4. What are different OOPs concepts?
  5. What is a class?
  6. What is an object?
  7. What are different object characteristics?
  8. What is polymorphism?
  9. What is static polymorphism?
  10. What is dynamic polymorphism?
  11. What is method overloading?
  12. What are rules of method overloading?
  13. Can we overload a static method in Java?
  14. What is method over-riding?
  15. What are rules of method over-riding?
  16. Can we override a static method in Java?
  17. Can we prevent overriding a method without using final keyword?
  18. Can we override a private method in Java?
  19. What is covariant method overriding in Java?
  20. Can we change the return type of a method to subclass while overriding?
  21. can we change the argument list of an overriding method?
  22. Can we override a method which throws runtime exception, without using throws clause?
  23. How do you call superclass version of an overriding method in subclass?
  24. Can we override a non-static method in Java?
  25. Can we override the final method in Java?
  26. Can we overload or override the main method in java?
  27. What is the difference between polymorphism, method overloading and method overriding?
  28. What is method hiding in Java?
  29. What is Inheritance?
  30. How is inheritance implemented in Java?
  31. What is multiple inheritance?
  32. Does java support multiple inheritance?
  33. What is the diamond problem in inheritance?
  34. Why does Java not support multiple inheritance?
  35. What is the meaning of ‘IS-A’ and ‘Has-A’ relationships?
  36. What is the difference between polymorphism and inheritance?
  37. What is abstraction?
  38. What is data hiding?
  39. What is an abstract class in Java?
  40. Can we have non-abstract method inside interface?
  41. What is the difference between abstraction and polymorphism in Java?
  42. What is an interface in Java?
  43. What is the real user of an interface?
  44. Can an interface extend more than one interface in Java?
  45. Can a class extend more than one class in Java?
  46. What is the difference between abstract class and interface?
  47. Can we make a class abstract without an abstract method?
  48. Can we make a class both final and abstract at same time?
  49. What is encapsulation?
  50. What is the difference between abstraction and encapsulation?
  51. What is Association?
  52. What is Aggregation?
  53. What is Composition?
  54. What is Dependency?
  55. What is the difference between association and dependency?
  56. Is Java a pure object oriented language? If not, why?
  57. What is the difference between object-oriented programming language and object based programming language?
  58. What is the default method of Java 8?

String Handling

  1. What is String constant pool in Java?
  2. How many objects are created in JVM when a String type variable is assigned using new keyword?
  3. How to create immutable class?
  4. Why String is immutable in Java?
  5. What is the difference between StringBuilder and StringBuffer?
  6. Why character array is preferred while storing password instead of String?
  7. What is the use of intern() method in java?
  8. Is String thread-safe?
  9. Where exactly string constant pool is located in the JVM?
  10. How substring method works in JDK 6 and JDK 7?

Exception Handling

  1. What is Exception Handling in Java?
  2. What is the difference between checked exception and unchecked exception?
  3. What is finally block?
  4. Explain exception hierarchy in Java.
  5. What is the difference between throw and throws?
  6. What is exception propagation?
  7. What is exception matching in Java?
  8. What is the difference between error and exception?
  9. What is OutOfMemoryError in Java?
  10. What is Re-throwing an exception in Java?

Serialization

  1. What is Serialization in Java?
  2. How to make a Java class Serializable?
  3. What is the difference between Serializable and Externalizable interface in Java?
  4. How many methods Serializable interface has? If no method then what is the purpose of Serializable interface?
  5. What is serialVersionUID?
  6. While serializing you want some of the members not to serialize? How do you achieve it?
  7. What will happen if one of the members in the class doesn’t implement Serializable interface?
  8. If a class is Serializable but its super class in not, what will be the state of the instance variables inherited from super class after de-Serialization?
  9. Can you Customize Serialization process or can you override default Serialization process in Java?
  10. Suppose super class of a new class implement Serializable interface, how can you avoid new class to being serialized?
  11. Which methods are used during Serialization and de-Serialization process in Java?
  12. Suppose you have a class which you serialized it and stored in persistence and later modified that class to add a new field. What will happen if you de-serialize the object already serialized?
  13. Can we transfer a serialized object via network?
  14. When will you use Serializable or Externalizable interface? and why?
  15. What are the ways to speed up Object Serialization? How to improve Serialization performance?
  16. What would happen if the SerialVersionUID of an object is not defined?
  17. What are transient variables? What role do they play in Serialization process?
  18. Why does serialization NOT save the value of static class attributes? Why static variables are not serialized?
  19. How to serialize a collection in java? How to serialize a ArrayList, HashMap or HashSet object in Java?
  20. Which kind of variables are not serialized during Java Serialization?

Garbage Collection

  1. What is garbage collection in java and what is gc()?
  2. What are the responsibilities of Garbage Collector?
  3. What are the different sections in JVM memory?
  4. How Java Heap is designed? What is Perm Gen space in Heap?
  5. How many types of GC algorithms are there in Java? Please explain.
  6. What are the different ways to call garbage collector?
  7. How to identify minor and major garbage collection in Java?
  8. What are the different ways to make an object eligible for Garbage Collection when it is no longer needed?
  9. How JVM destroy the un-referenced objects in Java?
  10. Can we guarantee objects destruction?
  11. When does an object become eligible for garbage collection? Can we force garbage collector?
  12. Can an un-referenced objects be referenced again?
  13. What is finalize() method in Java? When does Garbage collector calls finalize() in Java?
  14. When to use final, finally and finalize keywords?
  15. What is the difference between Serial and Throughput Garbage collector?
  16. How to enable /disable call of finalize() method of exit of application?
  17. Can we force Garbage collector to run at any time?
  18. Does Garbage collection occur in permanent generation space in JVM?
  19. What happens if an uncaught exception is thrown from during the execution of finalize() method of an object?
  20. What tools are used to analyze the Garbage Collection logs?

Multi-threading – Concurrent Java Programming

  1. What is Thread in Java?
  2. What is the difference between Thread and Process in Java?
  3. How you will implement Thread in Java?
  4. What is Java Memory model?
  5. What is race condition in Java?
  6. What is ThreadLocal variable in Java?
  7. Why wait and notify method are called from synchronized block?
  8. What is the difference between yield() and sleep() in Java?
  9. What is the use of wait() and notify() in java?
  10. What is thread pool? Why should you thread pool in Java?
  11. How do you check if a Thread holds a lock or not?
  12. How do you take thread dump in Java?
  13. What is the difference between the volatile and atomic variable in Java?
  14. What happens if a thread throws an Exception inside synchronized block?
  15. What is blocking method in Java?
  16. Why Thread sleep() and yield() methods are static?
  17. What will happens if I make a static method as synchronized?
  18. What is thread leak?
  19. Can we synchronize the run method? If yes then what will be the behavior?
  20. Can we synchronize the constructor of a Java Class?
  21. What is AtomicInteger in Java?
  22. How Threads implements their own Stack?
  23. What is the difference between time slicing and preemptive scheduling?
  24. How can you say behavior of Thread is unpredictable?
  25. Can you again start a thread?
  26. Why methods wait() and notify() are in Object class and not in Thread class?
  27. How to solve Producer-Consumer problem in Java?
  28. What are Java Synchronizers?
  29. What is thread starvation?
  30. What is a Deamon thread?

Inner Class

  1. What is inner class?
  2. What is nested class?
  3. Why use nested classes?
  4. How many types of nested classes are there in Java?
  5. Can we access non-static members of outer class inside a static nested class?
  6. What are member inner classes in Java?
  7. What is Inner Class Shadowing?
  8. How Serialization works in inner class?
  9. How to access the inner class from code within the outer class?
  10. What are disadvantages of using inner classes?

I/O

  1. What is a IO Stream?
  2. What are the differences between byte stream and character stream?
  3. What are FileInputStream and FileOutputStream?
  4. What is an IO Filter?
  5. What is StreamTokenizer?
  6. How many ways to read the data from keyboard?
  7. What are the difference between the File and RandomAccessFile classes?
  8. What are piped streams?
  9. What are filtered streams?
  10. Explain the functionality of SequenceInputStream?

Networking

  1. What is a socket?
  2. What is network programming?
  3. What are the differences between TCP and UDP?
  4. What are the important TCP Socket classes?
  5. What are the advantages and disadvantages of Java Sockets?
  6. What information is required to create a TCP Socket?
  7. What is the difference between URL instance and URL connection instance?
  8. Which class in Java is used to obtain a port and listen for client requests?
  9. What is SMTP?
  10. What is the Proxy Server?

Generics

  1. What are Generics in Java?
  2. How to declare a Generic Class in Java?
  3. What are the advantages of using Generic Types?
  4. What is the difference between generic method and generic type?
  5. What is Type Inference?
  6. What is Type Erasure?
  7. What is a Wildcard type?
  8. What is an upper Bounded and Unbounded Wildcards?
  9. What is difference between List<? extends T> and List <? super T>?
  10. How can we restrict Generics to a subclass of particular class?

Collection Framework

  1. How Arraylist works internally in Java?
  2. How LinkedList works internally in Java?
  3. How Vector works internally in Java?
  4. How CopyOnWriteArrayList works internally in Java?
  5. How HashMap works internally in Java?
  6. How Concurrent HashMap works internally in Java?
  7. What is the need of ConcurrentHashMap when there is HashMap and Hashtable already present?
  8. HashMap and Hashtable uses Array and Linkedlist as datastructure to store data, How is it different in ConcurrentHashMap?
  9. How ConcurrentHashMap is efficient in terms of Performance and Thread safety?
  10. Can multiple threads read and write from same or different Segments of ConcurrentHashMap simultaneously?
  11. What is the default size of Segment array? how it is tuned? What is ConcurrenyLevel in case of ConcurrentHashMap?
  12. What will happen if the size of Segment array is too small or too large?
  13. How Segment array size calculated?
  14. What is HashEntry array and how is the size of HashEntry calculated?
  15. How does ConcurrentHashMap handle rehashing while another thread is still writing on another segment/partition?

Reflection

  1. What is reflection in Java?
  2. Difference between introspection and reflection?
  3. What are the drawbacks of reflection in Java?
  4. What are the practical uses of Java reflection?
  5. How many ways are there to get a Class class object?
  6. What are the commonly used methods of Class class?
  7. How to call a method using reflection?
  8. How to access private fields and methods using reflection?
  9. How to get the super-class of a particular class?
  10. Why reflection is slow?

JDBC

  1. What is the general architecture of JDBC.
  2. What are the common JDBC API components?
  3. What is a JDBC Driver and DriverManager?
  4. What is a connection?
  5. What is difference between statement and prepared statement?
  6. How do you register a driver?
  7. What is a ResultSet?
  8. What is a Stored Procedure and how do you call it in JDBC?
  9. What are the design patterns used in JDBC?
  10. What are the benefits of JDBC 4.0?

Servlets

  1. How can you create a deadlock in servlet?

New Features in JDK versions

  1. JDK 1.5
  2. JDK 1.6
  3. JDK 1.7
  4. JDK 1.8
  5. JDK 1.9
LinkedIn Auto Publish Powered By : XYZScripts.com