Java - Interview Questions and Answers for 'Synchronized' | 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

   



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

 Q1. Why HashTable has been deprecated ?Core Java2016-07-08 10:01:58

Ans. HashTable has been Deprecated as an alternative ConcurrentHashMap has been provided which uses multiple buckets to store data and hence much better performance than hashtable. Moreover there is already a raw type hashmap. The only difference between the HashTable and HashMap is that Hashtable is synchronized whereas HashMap is not. Most of the synchronized collections have been deprecated and their raw alternative have been presented as preferred.

Synchronization has a cost. Using synchronized collection at a place where there is hardly any need of it would means useless utilization of resources. As these collections are rarely used in static context or shared among threads, Java might have thought it better to just provide the raw collection and let developer implement synchronization if he feels the need to do so.

As HashMap has been presented as default and preferred way of using Map with read optimized hashing, and ConcurrentHashMap has been provided for synchronized access which provides better performance than HashTable, Java thought it right to deprecate the use of HashTable.

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

   Like      Discuss      Correct / Improve     hashtable  synchronized collections  Why synchronized collections have been deprecated  Why HashTable has been deprecated  HashTable vs HashMap      expert

Try 3 Question(s) Test


Very frequently asked. Usually difference between String,StringBuffer and StringBuilder is asked in different variations.
  Q2. Difference between StringBuffer and StringBuilder ?Core Java
Anonymous
Ans. StringBuffer is synchronized whereas StringBuilder is not.

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

   Like      Discuss      Correct / Improve     java   string   stringbuffer   string class   stringbuilder   synchronized   basic interview question   infosys technologies     Thomson Reuters  Ludia  QualiTest  United Health Group (UHG)  Sophos  JPMorgan Chase  ebay  Infosys Technologies  Experian India      basic        frequent

Try 1 Question(s) Test


 Q3. What is a Property class ?Core Java
Anonymous
Ans. The properties class is a subclass of Hashtable that can be read from or written to a stream.

  Sample Code for Load Properties using Property Class

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

   Like      Discuss      Correct / Improve     java   collections   hashtable   map   synchronization   synchronized


 Q4. 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


Very frequently asked.
 Q5. What is the use of synchronized keyword ?Core Java2016-11-04 08:15:53

Ans. Synchronize is used to achieve mutual exclusion i.e at one time, the segment of the code, method that has been declared synchronized 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     threads  multithreading  synchronized     CapitalOne  Deloitte  JP Morgan  Morgan Stanley  JP Morgan      basic        frequent


 Q6. Is synchronized a keyword , modifier, identifier? what is it ?Core Java2017-04-26 19:48:55

Ans. synchronized is a keyword and a modifier. The synchronized keyword is used to indicate that a method can be accessed exclusively by one thread at a time.

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

   Like      Discuss      Correct / Improve     synchronization  synchronized  modifier  identifier     HCL Technologies


 Q7. What are the advantages and disadvantages of using lock classes from java.util.concurrent.locks vs. synchronized methods ?Core Java2017-05-07 19:30:42

 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     java.util.concurrent.locks  synchronization  synchronized methods


 Q8. What is the trade off between using Collections.synchronizedList() on an ArrayList and a CopyOnWriteArrayList?Core Java2017-05-07 19:31:54

 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     Collections.synchronizedList()  CopyOnWriteArrayList


 Q9. What is meant by "Vector is synchronized and ArrayList isn't " ?Core Java2017-06-08 07:32:02

Ans. It means that only 1 thread can access have access to Vector at a time and no parallel access is allowed whereas Array List allows parallel access by multiple threads.

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

   Like      Discuss      Correct / Improve     vectors  arraylist  collections  list  synchronization  synchronized


 Q10. Which of the following class is synchronized ?Core Java
a. String
b. StringBuffer
c. StringBuilder
d. None of these

Ans.b. StringBuffer



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: