Core Java Interview Questions – I

Q. What is System.out.println?

  • System = final System class
  • out          =  static PrintStream object
  • println = method of a printstrem class

Q. What is difference between abstract class and interfaces.

  • abstract class can provide implementation, interface has no implementation at all
  • used using extends, used using implements
  • both can not be instantiated


Q. What will be the output of following code snippet?

The program will be compiled without any errors, at run time it will throw NullPointerException.

Q. What will be the output of following code snippet.

The program will be compiled without any errors, at run time it will give an Error saying “Main Method not public”

Q. What is difference between sleep() and wait()?

When we say sleep(2000), then the thread sleeps for exact 2 seconds, but when we say wait(2000), the  thread might wake up on receiving notify() OR notifyall() call.

Q. What are serializable, externalizable interfaces?

These are interfaces used while serialization process. Serialization is a process in which object is converted in byte stream to transfer over network. Serializable acts as marker interface and externalizable is specialization of serializable interface with methods like readExternal, writerExternal, which gives you more control over serialization process.

Q. How threds are created?

In java threads can be created either by extending Thread class Or implementng Runnable Interface.We need to override run() method.

Q. Differenes between Vector and ArrayLists

  • ArrayLists are not synchronized while vectors are synchronized.
  • By default ArrayList grows by 50%  and Vector grows by 100%.

Q. What is difference between HashMap and HashTable

  • HashTable is synchronized and HashMaps are unsynchronizd
  • HashTable do not allow null as a key, HashMap allow null as key
2 Comments
  1. Antony
    January 13, 2012 | Reply
    • Pavan
      January 16, 2012 | Reply

Add a Comment

Your email address will not be published. Required fields are marked *