Prepare
Practice
Interview
Aptitude
Reasoning
English
GD
Placement papers
HR
Current affairs
Engineering
MCA
MBA
Online test
Login
Online Practice Test
>
Java
« Previous
Next »
Which of the following is synchronized?
Options
- Set
- LinkedList
- Vector
- WeakHashMap
CORRECT ANSWER : Vector
Discussion Board
java
vector
simple
its a package
and package is also called as
collection object
Tinku 04-6-2017 01:31 PM
ans
right ans
Tinku 04-6-2017 01:30 PM
Synchronised
Synchronised in the sense of collection framework is thread-safety.
Here Vector will providing thread-safety.
Rajeev 03-28-2017 01:02 PM
Synchronized Method
Vector is a type of collection object that Java has as it is used to implement AbstractList class. It is a synchronized method as it allows the means to run multiple threads and can safely read/modify data from a vector at the same time. In synchronized method only 1 thread can access to only 1 method at a time Vector contains collection of objects of any type and they provide the safe environment for the execution of methods. They are mostly used in muti-threaded system due to the secure environment that it provides. An example is given as:
public synchronized int size() {
return elementCount;
}
public synchronized E get(int index) {
if (index >= elementCount)
throw new ArrayIndexOutOfBoundsException(index);
return (E)elementData[index];
}
This way it makes the use of vector safe.
Rohit Sharma 07-27-2014 04:35 PM
Synchronize
Hi there,
synchronized keyword means that a thread needs a key in order to access the synchronized code.
In this question, Vector is synchronized. That means if a thread want to access the synchronized, it needs a key for Vector object
Nhung 01-24-2014 11:55 AM
Synchronize
What is meant by synchronized? I Chose the correct answer but I don't know why it was the correct answer.
Jeff 12-16-2013 04:12 PM
« Previous
Next »
Write your comments
*
*
Email must be in the form someone@domain.com
*
*
Enter the code shown above:
Please enter the code shown above
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)
Related Content
Java Beginner (11)
Java (39)
Java (40)
Java (22)
Java (30)
Java (25)
Java (20)
Java (20)
Core Java (20)
Core Java (10)
Core Java (72)
EJB (20)
JDBC (20)
Applet (20)
Struts (21)
Servlets (20)
Java Web Services (20)
Javascript (40)
J2EE (10)
jQuery (46)
Advertisement
▲