Wednesday, December 29, 2010

Questions on Java interview

Guys, I'd like to share with the (big) world my modest Java interviewing experience. Here are the questions which I pester job-candidates with:

Object Oriented Programming
  1. Central idea of Object Oriented Programming in one sentence
  2. Central idea of Structured Programming in one sentence

Core Java
  1. Multiple inheritance in Java (classes and interfaces)
  2. What are the differences between Interface and Abstract Class?
  3. What final classes in Java SDK you know? Why they are declared final?
  4. What are the (non-) final methods of Object class? Why?
  5. How to override Object.clone() method correctly?
  6. Collections
    • What is the difference between ArrayList and Vector?
    • How to sort a collection of your own classes?
    • [Senior] What sorting algorithm is used in Collections.sort()? Why?
    • How to filter out (i.e., remove some items) from ArrayList while iterating through it?
  7. Exceptions
    • Types and the difference
    • What kind of exception can you catch?
    • Is it safe to catch Throwable?
  8. Threads
    • What are the static and instance methods in a Thread class?
    • Why static methods in a Thread class are static and instance method are not?
    • What is the difference between Thread.sleep() and someObject.wait() methods?
    • What are the immutable objects? When to use?
    • [Senior] What are the reasons to use utils in the package java.util.concurrency?
    • [Senior] What is a ThreadLocal? How you can use it in production code?
  9. Serialization
    • How to make a class serializable?
    • Java IDEs shows us warning if the serializable class doesn't declare static final field of type long, "serialVersionUID". Why to worry?
  10. Class destruction
    • How and when override finalize() method?
    • [Senior] How does Garbage Collector work?
  11. Quirks
    • Is it possible to have two object of the given singleton class in one VM? If so - then how?
Enterprise Java
  1. Servlets: when servlet is instantiated?
  2. Servlets: how much servlet' instances of a same class simultaneously live in servlet container?
  3. Are servlets thread-safe?
Object-relational mapping
  1. What are the requirements for the Entity?
  2. Is it necessary to override Entity.equals()? How to implement Entity.equals()? What are the caveats?
  3. What is lazy loading? Is it dangerous?
Simple algorithms
  1. Transform given string "Bob doesn't eat dogs" to the new one "dogs eat doesn't Bob". String.split() usage is prohibited.
  2. Bubble sorting. Algorithm improvements.
  3. [Senior] How would you implement thread-safe hash map?
"Mmmmmmmm...." questions
  1. What a new trick/feature you'd found in Java?
  2. Which software pattern you are using most? Why?
  3. Why Multiple inheritance is bad?
  4. What is the latest IT technology you'd discovered for yourself?
  5. Which IT achievement you can be proud of?
Ideas for pair programming session
  1. Bubble sorting. Unit tests and  algorithm improvements
  2. Modelling computer network. Instances: domains, subdomains, hosts. Operations:add, delete, move, find. Unit tests.
  3. Echo server and client.
  4. Modelling animal farm. Instances: pig, cat, dog. Operations: create, feed, sound. Unit tests.
  5. Modelling computer network. Instances: domains, subdomains, hosts, settings (collection of key-value pairs). Operations: apply setting to host/domain, override set of parameters on host/domain. Unit tests.
  6. Modelling computer network. Instances: domains, subdomains, hosts. Operations: sort hosts according to their nesting(starting from root).

0 comments:

Post a Comment