Top 50 Java Interview Questions for Freshers

Carvia Tech | May 05, 2019 | 3 min read | 73 views


Core OOP Concepts

Collections Framework

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

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

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

  4. Discuss how Hashtable works?

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

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

  7. What is the difference between the size and capacity of a Vector? Answer : The size is the number of elements actually stored in the vector, while capacity is the maximum number of elements it can store at a given instance of time.

Concurrency & multi-threading

  • What is difference between Callable and Runnable interface?

  • 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? Give an example where you will you a ThreadLocal variable?

  • 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?

  • What is difference between Cluster and non-cluster index in RDBMS?

  • How is ManyToMany relationship implemented in database? Give a practical example of ManyToMany relationship?

  • What is difference between inner join and outer join?

  • When will you choose a RDBMS over NoSql and vice versa?

Unix OS

  1. How will you create a service in unix (ubuntu/centos) that automatically starts at reboot.

  2. How will you kill a process in linux?

  3. How to continuously check last 200 lines of a log file?

  4. How to find remaining disk space in linux server?

  5. How to make any script file executable?

  6. How to schedule a repeating job in UNIX using crontab?

  7. What is piping of commands in Unix? Any example?


Buy my ebook for complete question bank

Most of these questions has been answered in my eBook "Cracking the Core Java Interview" updated on June 2018, that you can buy from this link:

Buy from Shunya (DRM Free PDF download with updates)

Top articles in this category:
  1. Top 50 Multi-threading Java Interview Questions for Investment Bank
  2. Sapient Global Market Java Interview Questions and Coding Exercise
  3. UBS Top 10 Java Interview Questions
  4. BlackRock Top Java Interview Questions: Investment Banking Domain
  5. Citibank Java developer interview questions
  6. Morgan Stanley Investment Banking Java Interview Questions
  7. Goldman Sachs Java Interview Questions for Senior Developer


Find more on this topic:
Java Interviews image
Java Interviews

Interview - Product Companies, eCommerce Companies, Investment Banking, Healthcare Industry, Service Companies and Startups.

Last updated 1 week ago


Recommended books for interview preparation:

This website uses cookies to ensure you get the best experience on our website. more info