Top Java Interview Questions and Answers asking in MNC and all other companies for Freshers and Experienced
StoryLine:
“Each interview will give different experience. Whenever we prepare for any technical interviews, we will cover various topics from basic concepts to tricky questions. Enrichvia will share the experience from many developers who faced technical interview in ReactJS.”
Content:
Here are some essential Java questions to help you review important concepts:
Core Java Concepts:
1. What is the difference between JDK and JRE?
2. Why is Java platform-independent?
3. What is the difference between an abstract class and an interface?
4. What is the difference between final, finally, and finalize?
5. What is the difference between stack and heap memory?
6. What is method overloading vs. method overriding?
7. What’s the difference between a private and protected modifier?
8. What is constructor overloading in Java?
9. How is the super keyword used in Java?
10. What is the difference between static methods, variables, and classes?
11. What is System.out.println in Java?
12. What part of memory (Stack or Heap) is cleaned during garbage collection?
Object-Oriented Programming:
1. What Object-Oriented features are supported by Java?
2. What are the different access specifiers in Java?
3. What’s the difference between composition and inheritance?
4. What is the purpose of an abstract class?
5. What’s the difference between a constructor and a method?
6. What is the diamond problem in Java, and how is it resolved?
7. How do local and instance variables differ?
8. What is a Marker interface in Java?
Data Structures and Algorithms:
1. Why are strings immutable in Java?
2. What’s the difference between creating a String using new() and as a literal?
3. What is the Collections framework?
4. How do ArrayList and LinkedList differ?
5. What is the difference between a HashMap and a TreeMap?
6. How do HashSet and TreeSet differ?
7. What’s the difference between an Iterator and a ListIterator?
8. What is the purpose of the Comparable interface?
9. What is the java.util.concurrent package for?
Exception Handling:
1. What is an exception in Java?
2. How does exception propagation work?
3. What’s the difference between checked and unchecked exceptions?
4. What is the use of the try-catch block in Java?
5. How do throw and throws differ?
6. What is the use of the finally block?
7. What’s the base class of all exception classes?
Multithreading:
1. What is a thread, and what are its stages in Java?
2. How do threads differ from processes?
3. What are the different types of thread priorities in Java?
4. What is context switching in Java?
5. What’s the difference between user threads and Daemon threads?
6. What is synchronization in Java?
7. What is a deadlock in Java?
8. How are the wait() and notify() methods used?
9. What’s the difference between synchronized and volatile in Java?
10. What’s the purpose of the sleep() method?
11. How do wait() and sleep() differ?
12. What’s the difference between notify() and notifyAll()?
Java Enterprise Edition (Java EE):
1. What is Java EE?
2. How do Servlets and JSP differ?
3. What is the purpose of the Java Persistence API (JPA)?
4. What’s the difference between stateful and stateless session beans?
?
The basic aim of String Handling concept is storing the string data in the main memory (RAM), manipulating the data of the String, retrieving the part of the String etc. String Handling provides a lot of concepts that can be performed on a string such as concatenation of string, comparison of string, find sub string etc.
() ==?
equals() method always used to comparing contents of both source and destination String. It returns true if both strings are the same in meaning and case otherwise it returns false.
== Operator is always used for comparing references of both source and destination objects but not their contents.
, ?
is a keyword which means no more changes.
It can be applied to variables, methods, and classes, each with its own implications:
: Cannot be Re-initialized.
: means that the method cannot be overridden by subclasses.
: Cannot be inheritance.
: it’s a block and always associated with try catch block to maintain cleanup operations
: It’s a Method and when the garbage collector runs, it may lead to resource leaks.
?
A new keyword is used to allocate memory at runtime, new keyword is used for create an object of class
?
No, constructor cannot be synchronized. Because the constructor is used for instantiating objects, when we are in the constructor the object is under creation. So, until the object is not instantiated it does not need any synchronization.
?
If the thread is in new or dead state no memory is available but sufficient memory is available if that is in ready or running or waiting state.
?
Allowing only one thread at a time to utilized the same resource out of multiple threads is known as thread synchronization or thread safe.
?
Whenever multiple threads are trying to use same resource than they may be chance to of getting wrong output, to overcome this problem thread synchronization can be used.
Conclusion:
Java developers have huge market all over world. They can enrich web with good system and server side programming for all sectors based on client needs. Becoming Java developer should have good knowledge in OOPS, Server-Side programming and Data Structure.