Java Multithreading Interview Questions and Answers for Freshers - 2
Question: 6
What is the use of volatile in Java?
Threads are allowed to hold the values of variables in local memory (e.g. in a machine register)
If a variable is marked as volatile, every time when the variable is used, it must be read from the main memory, similarly every time the variable is written, the value must be stored in main memory.
Question: 7
What is the difference between multithreading and multitasking?
A Web Server understands and support only HTTP protocol whereas the Application Server supports HTTP, TCP/IP and many more protocols.
Also many more features such as Caches, Clusters, Load Balancing are there in Application Servers which are not available in Web Servers.
We can also Configure Application Servers to work as Web Server.
In Application Server is a super set of which Web Servers is a subset.
Question: 8
What is the difference between process and thread?
Process |
Thread |
A program Can run on its own Unit of allocation Have its own memory space Each process has one or more tables Expensive, need to context switch More sucure. One process cannot corrupt another process. |
Similar to a sequential program Cannot run on its own Unit of execution Share with others Each thread belongs to one process Cheap, can use process memory and may not need to context switch Less secure. A thread can write the memory used by another thread. |
Question: 9
Is there a separate stack for each thread in java?
No
Question: 10
Can a lock be acquired on a class?
Yes, a lock can be acquired on a class. This lock is acquired on the class’s Class object.
- Java Multithreading Interview Questions and Answers for Freshers
- Top 100+ Java Multithreading Interview Questions and Answers
- Top 100+ Advanced Multithreading Interview Questions 2019-2020
- Java Interview Questions and Answers for Experienced Professionals
- Java 9 Interview Questions for 1,2,3,4,5,6,7,8,9,10 Years Experience
Signals and Systems Quiz Questions and Answers Pdf More
Signals and Systems MCQ Questions and Answers Pdf More
Electrical Power Sources Quiz Questions & Answers Pdf More
Electromagnetic Field Theory Question Bank 2024-2025 More
Power Semiconductor Device and Integrated Circuits Questions More
1000+ Mechanical Engineering Question Papers for Competitive Exams More
Commonly Misspelled Words Quiz Questions More
Top 100+ Indian Economy Multiple Choice Questions and Answers More
Buddhism and Jainism TNPSC, UPSC, SSC MCQ Quiz Questions Pdf More
7000+ Fill in the Blanks with Suitable Homophones More