Pages

Wednesday 5 June 2013

Java Interview Questions

  1. What is the difference between an Interface and an Abstract class.
  2. What is the purpose of garbage collection in Java, and when is it used.
  3. Describe synchronization in respect to multithreading.
  4. Explain different way of using thread.
  5. What are pass by reference and passby value.
  6. What is HashMap and Map.
  7. Difference between HashMap and HashTable.
  8. Difference between Vector and ArrayList.
  9. Difference between Swing and Awt.
  10. What is the difference between a constructor and a method.
  11. What is an Iterator.
  12. What is an abstract class.
  13. What is static in java.
  14. What is final.
  15. What if the main method is declared as private.
  16. What if the static modifier is removed from the signature of the main method.
  17. What if I write static public void instead of public static void.
  18. What if I do not provide the String array as the argument to the method.
  19. What is the first argument of the String array in main method.
  20. If I do not provide any arguments on the command line, then the String array of Main method will be empty or null.
  21. How can one prove that the array is not null but empty using one line of code.
  22. What environment variables do I need to set on my machine in order to be able to run Java programs.
  23. Can an application have multiple classes having main method.
  24. Can I have multiple main methods in the same class.
  25. Do I need to import java.lang package any time? Why.
  26. Can I import same package/class twice? Will the JVM load the package twice at runtime.
  27. What are Checked and UnChecked Exception.
  28. What is Overriding.
  29. What are different types of inner classes.
  30. What is the difference between declaring a variable and defining a variable.
  31. What is the default value of an object reference declared as an instance variable.
  32. Can a top level class be private or protected.
  33. What type of parameter passing does Java support.
  34. Primitive data types are passed by reference or pass by value.
  35. Objects are passed by value or by reference.
  36. What is serialization.
  37. How do I serialize an object to a file.
  38. Which methods of Serializable interface should I implement.
  39. How can I customize the seralization process? i.e. how can one have a control over the serialization process.
  40. What is the common usage of serialization.
  41. What is Externalizable interface.
  42. When you serialize an object, what happens to the object references included in the object.
  43. What one should take care of while serializing the object.
  44. What happens to the static fields of a class during serialization.
  45. Does Java provide any construct to find out the size of an object.
  46. Give a simplest way to find out the time a method takes for execution without using any profiling tool.
  47. What are checked exceptions.
  48. What are runtime exceptions.
  49. What is the difference between error and an exception.
  50. How to create custom exceptions.
  51. If I want an object of my class to be thrown as an exception object, what should I do.
  52. If my class already extends from some other class what should I do if I want an instance of my class to be thrown as an exception object.
  53. Is it necessary that each try block must be followed by a catch block.
  54. If I write return at the end of the try block, will the finally block still execute.
  55. How are Observer and Observable used.
  56. What is synchronization and why is it important.
  57. How does Java handle integer overflows and underflows.
  58. Does garbage collection guarantee that a program will not run out of memory.
  59. What is the difference between preemptive scheduling and time slicing.
  60. What is the purpose of finalization.
  61. What is the difference between a while statement and a do statement.
  62. What is the difference between static and non-static variables.
  63. How are this() and super() used with constructors.
  64. What are synchronized methods and synchronized statements.
  65. What is daemon thread and which method is used to create the daemon thread.
  66. Can applets communicate with each other.
  67. What are the steps in the JDBC connection.
  68. How does a try statement determine which catch clause should be used to handle an exception.
  69. Can an unreachable object become reachable again.
  70. What method must be implemented by all threads.
  71. What are synchronized methods and synchronized statements.
  72. What is Externalizable.
  73. What modifiers are allowed for methods in an Interface.
  74. What are some alternatives to inheritance.
  75. What does it mean that a method or field is "static".
  76. What is the difference between preemptive scheduling and time slicing.
  77. What is the catch or declare rule for method declarations.
  78. What will be the initial value of an object reference which is defined as an instance variable.
  79. What are the different scopes for Java variables.



No comments:

Post a Comment