Java - Interview Questions and Answers for 'Concurrency' | Search Java Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com
Share

Search Java Interview Questions


 2137 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



Java Concurrency in Practice


   




Interview Questions and Answers for 'Concurrency' - 10 question(s) found - Order By Newest

Frequently asked to fresh graduates and less experienced developers.
 Q1. Explain multithreading in Java ?Core Java
Anonymous
Ans. 1. Multithreading provides better interaction with the user by distribution of task

2. Threads in Java appear to run concurrently, so it provides simulation for simultaneous activities.The processor runs each thread for a short time and switches among the threads to simulate sim-ultaneous execution (context-switching) and it make appears that each thread has its own processor.By using this feature, users can make it appear as if multiple tasks are occurring simultaneously when, in fact, each is running for only a brief time before the context is switched to the next thread.

3. We can do other things while waiting for slow I/O operations.In the java.iopackage, the class InputStreamhas a method, read(), that blocks until a byte is read from the stream or until an IOExceptionis thrown. The thread that executes this method cannot do anything elsewhile awaiting the arrival of another byte on the stream.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   threads   multi threading  concurrency   multithreading     Hamsini ECommerce   Cognizant (CTS)  Cumulus Systems  Cognizant (CTS)      intermediate        frequent

Try 1 Question(s) Test


Frequently asked to fresh graduates.
  Q2. What is a Deadlock ?Operating System
Anonymous
Ans. When two threads are waiting each other and cant precede the program is said to be deadlock.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   threads   multi threading   operating system   deadlock  concurrency     Lime Wire  Perfect Sense  QuantCast  Aequitas NEO Exchange  Akuna Capital  Juniper Networks  Casale Media  Netflix  NetApp  Apple  AIG  Cpart  SnapStream Media  Cumulus Systems  Wissen Infotech  HedgeServ Corp  KeyIdeas Infotech  Verint Systems  BlackBerry  EverQuote      basic        frequent


 Q3. What is race condition ?Operating System
Admin
info@buggybread.com
Ans. A source of possible errors in parallel programming, where one thread can cause an error in another thread by changing some aspect of the state of the program that the second thread is depending on (such as the value of variable).

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java.threads   multithreading   race condition   parallel programming   synchronization   ebay   concurrency     ISB Vietnam  NetSpend  Polycom  Cerner  NVIDIA  US Bank  Amadeus  McKesson  Hulu  Neelkanth Digital


 Q4. What is the use of runnable interface if we can always create a new thread using Thread class ?Core Java
Admin
info@buggybread.com
Ans. It's a choice to be made whether to use first approach ( Thread class ) or second approach ( runnable interface ) by the programmer. The second facility has been given for cases where your class is already extending some parent class and hence cannot extend another class ( for Thread ) as Java doesn't allow multiple inheritance.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   threads   multithreading   runnable interface  concurrency


 Q5. When you will synchronize a piece of your code?
Admin
info@buggybread.com
Ans. When you expect your code will be accessed by different threads and these threads may change a particular data causing data corruption.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   threads   multi threading   synchronization   concurrency      basic        frequent


 Q6. What is a ConcurrentHashMap ?Core Java
Admin
info@buggybread.com
Ans. ConcurrentHashMap is a hashMap that allows concurrent modifications from multiple threads as there can be multiple locks on the same hashmap.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   hashmap   map   concurrenthashmap   concurrenthashmap  concurrency   general electric   ge     Cognizant (CTS)  Synechron  General Electric  MakeMyTrip.com  Nomura Securities  Xpanxion  Royal Bank of Scotland (RBS)  ProKarma  Talentica  Citi  EdgeVerve Systems  Six Dee Telecom  ReqRoute  Qumulo  Goldman Sachs  HSBC Holdings  AlertMe.com  BlackRock  Helpchat  Bally Technologies  Hubzu  Xpanxion  Coromandel Infotech  Paytm  YuMe  InfoGain  Markit  Wells Fargo  Geometric  Acloudzyn Technologies  Roposo        rare


 Q7. What is ConcurrentModificationException ?Core Java
Admin
info@buggybread.com
Ans. This is the exception that is thrown when we try to modify the non concurrent collection class while iterating through it.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   concurrentmodificationexception   exception  concurrency     Calypso Technology  Deloitte  IRIS Software      intermediate


 Q8. What is the use of Synchronized block ?Core Java

Ans. The goal of a synchronised block is to achieve mutual exclusion i.e at one time, the segment of the code should be executed by single thread only and hence the lock needs to be retrieved before executing the segment and then released.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     synchronized block   synchronized   synchronization   multithreading   threads   mutual exclusion   concurrency     Capgemini  Cognam Technologies  hewlett packard (HP)  BlackRock      intermediate        frequent

Try 1 Question(s) Test


 Q9. Explain Java 8 concurrency mechanism.Core Java2017-07-22 07:52:01

 This question was recently asked at 'IBM'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     synchronization  concurrency  java 8  java8     IBM



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q10. If you need to consume messages from the queue faster, which approach will you recommend - batching or concurrency ?Design2017-07-24 13:34:47

Ans. Each has it's own advantages

Batching requires less resources but may result in loosing whole batch in case of failure whereas concurrency even though is little more expensive in terms of resources but would result in minimal loss in case of failure.

In case messages are to be consumed in a particular order, batching them in that order and then consuming them makes better sense.

if incoming messages are not continuous , it makes more sense to do concurrency as we need not wait for all messages to form a batch and flush. Though time sensitivity can be added but that would add unnecessary complexity.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     concurrency vs batching   concurrency  multithreading  batch




Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: