Wednesday, January 20, 2016

Top 50 Java Interview Questions for Freshers (0-3 Years experience)

Popular Java Interview Questions for Freshers Interview (0-3 years of java experience)

Core OOP Concepts

  • Is Java pure Object Oriented Programming Language ? Check Answer
  • What is difference between String, StringBuilder and StringBuffer ?
  • Is it possible for a Java method to inline swap two int or integer values ? Discuss pass-by-reference vs pass-by-value ?
  • What is difference between JRE and JDK
  • What is difference between 32bit and 64bit JDK ? Does size of primitive type changes between these two variants ?
  • How Garbage Collection Works ? What are different Space partitions inside JVM (PermGen, Eden Space, etc)
  • If a method throws Nullpointer exception in super class, can subclass method override it to throw RuntimeException ?
    Answer : http://javainterviews.scribbleit.in/core-java/java-method-override-rules-for-runtime-exceptions

Collections Framework

Q. What is the criteria for a class to be eligible for key in Hashmap ?

Answer : http://javainterviews.scribbleit.in/core-java/class-criteria-for-making-it-hashmap-key

Q. What are benefits of making a class Immutable ? How will you make a class Immutable ?

Answer : http://javainterviews.scribbleit.in/core-java/concept-of-immutable-class-in-java-concurrency

Q. What is difference between ArrayList and Vector? Which one shall be preferred?

Answer : http://javainterviews.scribbleit.in/core-java/vector-vs-arraylist-java-collections

Q. Discuss how Hashtable works ?

Answer : http://javainterviews.scribbleit.in/core-java/discuss-internals-of-concurrent-hashmap-in-java

Q. Write code to remove entries from hashmap while iterating over it ?

Answer : http://javainterviews.scribbleit.in/core-java/add-remove-entries-from-hashmap-during-iteration

Q. What is difference between fail-safe and fail-fast iterators ? Give example of each in Java Collections framework ?

Answer : http://javainterviews.scribbleit.in/core-java/fail-safe-vs-fail-fast-iterator-in-java-collections

Concurrency & multi-threading

  • The difference between sleep and wait in Java?
  • Difference between Callable and Runnable interface ? Check Answer
  • Explain visibility and atomicity problems faced in multi-threaded environment?
  • What is use of Volatile variables in Java ? Explain working of volatile with respect to register cache & main heap memory?
  • Can volatile keyword be used to make a non-atomic operation as atomic?
  • What is difference between wait() and sleep() method in Java?
  • How will you implement a thread-safe singleton in Java?
  • Which one of the following would be easy to write? thread-safe code for for 10 threads or 2 threads?
  • How do you call wait() method? using if block or loop? Why? Provide a example for your explanation.
  • How do you take thread dump in Java on Windows and Unix machine?
  • What is a thread local variable in Java?
  • Write wait-notify code for producer-consumer problem?
  • What is an immutable object? How and why do you create an Immutable object in Java?

Database

  • How will you join two Tables A and B where data in Table B is optional, i.e. even if no matching record exists in Table B, rows of Table A shall appear in the query result ?
    Answer : Hint is Left Outer Join between A and B
  • How will you find nth highest salary from Employee Table using SQL ?

No comments:

Post a Comment

Your comment will be published after review from moderator