Friday, 16 September 2011

Core Java Questions

After nearly a decade in Java world, it is time to think about the basics (most people say Core Java). Anyone that has been in the Java industry for a long time should know the answer to all of the following questions, and if not, it is time to refresh your memory and maybe get excited again on what made you like Java in the first place. I'm not going to provide the answers since they are just a Google away, so here we go:
  • What is the difference between ArrayList and Vector?
  • What are the differences between Comparable and Comparator?
  • Name design patterns that you use in Java. Give some examples.
  • Implement a Singleton design pattern in Java. Why Singleton? Is the Singleton class that you created thread safe? What about the clone() method?
  • What are the differences between Heap, Perm and Stack space?
  • Explain how HashMap works in Java. Which method/s are used when put() or get() is called? What is the benefit of having immutable keys in HashMap?
  • Explain how Java Garbage Collection works. Explain in terms of young generation, survivor 1 and 2, tenured generation and permanent generation. Can you force garbage collection?
  • What JVM memory tuning options can you use to improve performance?
  • Explain how Serialization works in Java. Include methods that are involved during the serialization/deserialization. What is serialVersionUID? What could happen when serialVersionUID is missing?
  • What's so special about declaring a variable in a Java interface?
  • What is the difference between executing run() and start() in Java thread?
  • Explain why String is immutable? If it weren't, what would be the implications?
  • Can you write an immutable object?
  • What is the difference between creating String using new() and literal?
  • What is the difference between Enumeration and Iterator?
  • Explain deadlock. What would you check in the code that might cause deadlocks?
  • Explain Checked and Unchecked Exception.
  • When is finalize() method called?
  • Explain transient modifier.
  • Explain volatile modifer.
  • What is the difference between public, private and default?
  • What is operator precedence in Java?
  • What is the difference between abstract class and interface?
  • What is the difference between method override and method overload?
  • Explain polymorphism, inheritance, and encapsulation.
  • What is a wrapper class?
  • Explain autoboxing
  • Why would you use synchronized block instead of synchronized method?
  • What is the difference between method wait() and sleep()?
  • What is the difference between & and && operator?
  • What is the difference between >> and >>> operator?
  • In JDBC, which one is faster, Statement or PreparedStatement? Why?
I will be adding more questions later. Stay tuned!
blog comments powered by Disqus