Since last year I received so far almost ~50 emails asking about why not to post
Java Interview Questions and answers for readers. I have been thinking about this since last week and finally decided to put top Java Interview questions on Crunchify.
Please note – there is no such thing about best Interview questions but we can try our best to cover all basic fundamentals about Java, Spring MVC, Maven, Apache Tomcat and J2EE tips in this interview sessions.
This is a
1st part of the Java Interview Questions and we do have top 10 in this post. Provide your
feedback and suggestions if you want us to put
next top 10 interview questions.
Also, if you below all questions then you are at right place.
- java interview questions and answers for freshers
- best java interview questions
- advanced java interview secrets
- java interview questions for experienced
- java programming interview questions
- java interview questions and answers for 3 years experience
- java interview questions for experienced professionals
- java interview questions for 5 years experience
Let’s get started…
Interview Question 1:
What are the main 3 Object Oriented Programing (OOP) concepts?
Encapsulationis a mechanism by which developer could hide implementation behind an interface.
- Encapsulated code has two features:
- Instance variables are kept protected (usually with the private modifier).
- Getter and setter methods provide access to instance variables.
- Kindly take a look at tutorial: Complete End to End working Encapsulation example
- The public
getName()methods are the access points of the instance variables.
- The public
- Inheritance allows a class to be a subclass of a superclass, and thereby inherit
public and protected
variables and methodsof the superclass.
- Inheritance is a key concept that underlies
Polymorphismmeans “many forms.”
- A reference variable is always of a single, unchangeable type, but it can refer to a subtype object.
- A single object can be referred to by reference variables of many different types —as long as they are the same type or a supertype of the object.
- Polymorphic method invocations apply only to overridden instance methods.
Interview Question 2:
Are you aware of Daemon Thread in Java?
Daemon threads in Java are like a service providers for other threads or objects running in the same process as the daemon thread. Daemon threads are used for background supporting tasks and are only needed while normal threads are executing. If normal threads are not running and remaining threads are daemon threads then the interpreter exits.
Kindly take a look at complete example: https://crunchify.com/what-is-daemon-thread-in-java-example-attached/
Interview Question 3:
What is Singleton Pattern and Do you know how to make it Thread-Safe and Fast?
singleton pattern is a design pattern that restricts the instantiation of a class to
one object. This is useful when exactly one object is needed to coordinate actions across the system.
Kindly take a look at detailed example: https://crunchify.com/thread-safe-and-a-fast-singleton-implementation-in-java/
Interview Question 4:
What is JVM? Are you aware of Heapsize, Stacksize & Garbage Collection? Please share some more light.
When a Java program starts, Java Virtual Machine gets some memory from Operating System. Java Virtual Machine or JVM uses this memory for all its need and part of this memory is call java heap memory.
Please take a look at detailed tutorial: https://crunchify.com/jvm-tuning-heapsize-stacksize-garbage-collection-fundamental/
Interview Question 5:
Write a program in Java which Counts total number of Characters, Words and Lines
This one is the more frequently asked question. Please visit complete tutorial for more info: https://crunchify.com/how-to-read-file-in-java-and-count-total-number-of-characters-words-and-lines/
Interview Question 6:
What is JSON and How to read JSON object from file?
Interview Question 7:
What is Semaphore and Mutex in Java. Provide detailed explanation related to MultiThreading
Java Concurrency is a very wide topic. There are hundreds of tutorials and examples available for use to use. Some time back I’ve written few tutorials on Run Multiple Threads Concurrently in Java and different types of Synchronized Blocks.
Kindly visit detailed tutorial for more explaination: https://crunchify.com/what-is-java-semaphore-and-mutex-java-concurrency-multithread-explained-with-example/
Interview Question 8:
Are you aware of HashMap, ConcurrentHashMap, SynchronizedMap? Which one is faster?
HashMap is a very powerful data structure in Java. We use it everyday and almost in all applications. I would suggest you to visit tutorial for more details: https://crunchify.com/hashmap-vs-concurrenthashmap-vs-synchronizedmap-how-a-hashmap-can-be-synchronized-in-java/
Interview Question 9:
What is Abstract Class and Interface in Java?
This one is also very popular Java interview questions. This is very big topic and we do have complete tutorial with all details here.
Interview Question 10:
How familiar are you with Spring MVC? Please provide some details.
Please visit below 3 tutorials which covers all basic on Spring MVC:
NOTE: On Crunchify we do have more than
500 Java tutorials. Let us know if you are looking for some more tutorials which are not part of the list.
Join the Discussion
Share & leave us some comments on what you think about this topic or if you like to add something.