Core Java Interview Questions for Experienced 5–8 years

Veenarao
4 min readNov 4, 2023

--

Dear Readers, this article will cover Core Java interview questions and Java-8

Core Java Interview Questions for Experienced
Core Java Interview Questions for Experienced

I’ve attended numerous interviews for software engineering positions in most of the MNCs. These were the commonly asked questions across all the interviews.

Hope this article helps you to prepare for your Interviews well and to understand the ability of using the concepts clear.

Strings:

  1. Why are strings immutable in java?
  2. How intern() works?
  3. How many objects are created in Strings using string literals and new operator?
  4. How string constant pool works?
  5. Difference between equals and == operator?
  6. Difference between string , string buffer and string builder.

Object:

  1. Why is wrapper class required?
  2. Methods of Object class?
  3. Does java gives importance to primitive data types?
  4. Is Java pass by value or pass by reference?

Oops

  1. Types of oops
  2. Composition vs Aggregation vs Association?
  3. Function overloading vs overriding
  4. Difference between Abstract class and Interface?
  5. Can private method or static methods be overridden in Java?
  6. Can main() method be overloaded?
  7. Can Abstract class have main method?

Serialisation

  1. What is Serialisation and Deserialisation?
  2. Use of transient keyword?
  3. Is it possible to serialise a class if its super class is not serialisable ?Can the class be still serialised and deserialised?

Answer: yes provided that non-serialisable super class has no args constructor which is involved at deserialisation to initialise the super class.

4. Can Uninitialised non serialised , non transient fields still be tolerated?Answer: yes

Cloning

  1. What is marker interface?
  2. What is shallow copy and Deep copy?

Exception

  1. Difference between Error and Exception?
  2. Checked vs Unchecked Exception?
  3. Create custom Exception?
  4. What is Runtime exception ?
  5. How does JVM handle Exception?
  6. Difference between Final, Finalise and Finally?
  7. Super class of all exceptions?
  8. Is throwable an interface?
  9. When Finally block doesn’t get executed?
  10. Can subclass throw higher checked exception than base class?
  11. Can we throw an unchecked exception in child class if parent class doesn’t throw any exception?
  12. Difference between throw and throws()

Usage of Enum

  1. Why to use Enum?

Garbage collection

  1. How does Garbage collection in Java works?

Collection

  1. Array vs ArrayList?
  2. ArrayList vs LinkedList? When to use which collection?
  3. Fail Safe vs Fail Fast Iterators?
  4. What is concurrent modification exception?
  5. Internal working of HashMap
  6. Java8 changes to HashMap
  7. Why HashMap contains null key?
  8. Is it Mandatory to have key immutable in HashMap?
  9. Why to override equals() and hashcode() method?
  10. HashSet vs LinkedHashSet vs TreeSet
  11. What is the Internal Datastructure in TreeMap? How the elements are sorted?
  12. HashMap vs ConcurrentHashMap
  13. Comparable vs Comparator
  14. What is blocking Queue?
  15. What is Vector? When to use it?

MultiThreading

  1. MultiThreading vs MultiProcessing vs MultiProgramming vs MultiTasking?
  2. Life cycle of a Thread
  3. Extends vs Runnable
  4. yield() vs sleep() vs join() ?
  5. wait() vs sleep() ?
  6. why is join() method used?
  7. Can we Override start() method in Thread?
  8. Can we Override run() method?
  9. Can we start the thread twice?
  10. What is IllegalThreadStateException?
  11. What happens if run() method is called without start()?
  12. Why do we use ThreadPool?
  13. What is Race Condition?
  14. What is Synchronisation?Types of Synchronisation?
  15. Object Level Locking vs Class Level Locking?
  16. If there is 2 synchronised methods m1 and m2 in a class, can 2 different threads t1 and t2 call different methods(m1,m2) respectively on same object of class c at same time ?
    Answer — No. Only 1 Thread can hold the lock on a object of a class.However the other non synchronised methods can be called on same object.
  17. If a class has a synchronised method and non synchronised method, can multiple threads execute non synchronised methods?
    Answer: yes. If a class has a synchronised method and non synchronised method , multiple threads can access non synchronised methods.
  18. Can 2 threads call 2 different static synchronised methods of same class?
    Answer : The static synchronised methods of same class always block each other as 1 lock per class exists. So no 2 static synchronised methods can execute at the same time.
  19. Does static synchronised methods block a non synchronised methods?
    Answer: No. The thread executing static synchronised method holds a lock on the class and the executing the non static synchronised method holds lock on the object on which the method has been called, these 2 locks are different and these threads dont block eachother.
  20. Can Constructors be synchronised?
  21. What is DeadLock?
  22. What is Inter thread communication?Explain wait(),notify() and notifyall()?
  23. What is IllegalMonitorStateException?
  24. Which class does wait(),notify() and notifyall() method belong?
  25. Explain few Thread class methods?is Sleep() a method in Thread class or Object class?
  26. Producer Consumer Problem in Java?
  27. Volatile vs Synchronised?
  28. What are Atomic variables?

Concurrency

  1. runnable vs callable ?
  2. What is Future Object?
  3. What is CompletableFuture?
  4. Use of Done() , IsCancelled() and Cancel() method of Future Object?
  5. Explain ThreadLocal class
  6. What is CountDownLatch?
  7. What is CyclicBarrier?
  8. What is ReEntrant lock?
  9. ExecutorService.submit() vs Executor.execute()?
  10. Different types of ThreadExecutor Services?
  11. Explain how FixedThreadPool executor works?

Java 8

  1. Interface8 changes
  2. What is Functional Interface? why do we need it?
  3. Difference between Collection and Stream
  4. What is Terminal Operator vs Intermediate operators?
  5. What is Optional?
  6. Flatmap vs Map?
  7. Difference between Parallel sort vs sort
  8. Difference between Predicate vs BiPredicate?
  9. How Diamond problem is solved in Java8?

Other

  1. Difference between JDK,JRE and JVM
  2. What is Immutable class?
  3. What are solid principles?
  4. Difference between ClassNotFound vs NoClassDefError?
  5. What is Singleton Design pattern?Explain ThreadSafe Singleton and Bill Pugh Singleton ?
  6. How to break Singleton?
  7. Explain few features in each Java versions starting from Java8
  • Thank you for reading this article. Please provide your valuable suggestions/ feedback.
  • Clap and Share if you liked the content.
  • 📰 Read more content on my Medium (on Java Developer interview questions)
  • 🔔 Follow me on : LinkedIn

Please find my other useful articles on Java Developer interview questions

Following are some of the famously asked Java8 Interview Questions

Frequently asked Java Programs

Dear Readers, these are the commonly asked java programs to check your ability on writing the logic

--

--