Java
Pages
Home
Java
Interview
Monday, 21 December 2015
Thread Concurrency Java - MCQ set 1 (30 questions, 68 marks)
Thread Concurrency Java - MCQ set 1 (30 questions, 68 marks)
Q1 - Q22, 22 MEDIUM level difficulty questions 2 mark each. 2 * 22 = 44 marks
Semaphore is found in which package in thread concurrency in java?
a.
java.util.concurrent
b.
java.util
c.
java.io
d.
java.lang
Semaphore was introduced in which java version
a.
java 5
b.
Java 6
c.
java 7
d.
java 8
Semaphore is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
Callable is found in which package in thread concurrency in java?
a.
java.util.concurrent
b.
java.util
c.
java.io
d.
java.lang
Callable was introduced in which java version
a.
java 5
b.
Java 6
c.
java 7
d.
java 8
Callable is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
Future is found in which package in thread concurrency in java?
a.
java.util.concurrent
b.
java.util
c.
java.io
d.
java.lang
Future was introduced in which java version
a.
java 5
b.
Java 6
c.
java 7
d.
java 8
Future is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
RecursiveTask is found in which package in thread concurrency in java?
a.
java.util.concurrent
b.
java.util
c.
java.io
d.
java.lang
RecursiveTask was introduced in which java version
a.
java 5
b.
Java 6
c.
java 7
d.
java 8
RecursiveTask is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
ForkJoinTask is found in which package in thread concurrency in java?
a.
java.util.concurrent
b.
java.util
c.
java.io
d.
java.lang
ForkJoinTask was introduced in which java version
a.
java 5
b.
Java 6
c.
java 7
d.
java 8
ForkJoinTask is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
RecursiveAction is found in which package in thread concurrency in java?
a.
java.util.concurrent
b.
java.util
c.
java.io
d.
java.lang
RecursiveAction was introduced in which java version
a.
java 5
b.
Java 6
c.
java 7
d.
java 8
RecursiveAction is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
ForkJoinPool is found in which package in thread concurrency in java?
a.
java.util.concurrent
b.
java.util
c.
java.io
d.
java.lang
ForkJoinPool was introduced in which java version
a.
java 5
b.
Java 6
c.
java 7
d.
java 8
ForkJoinPool is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
What method of java.util.concurrent.Callable interface returns value
a.
calling() method
b.
run() method
c.
runnable() method
d.
call() method
Q23 - Q30, 8 HARD level difficulty questions 3 mark each. 3 * 8 = 24 marks
What is significance of using Fork/Join Framework in thread concurrency in java?
a.
Fork/Join Framework has been added in JDK 7
b.
Fork/Join framework enables parallel programming. Parallel programming improves program performance
c.
Parallel programming means taking advantage two or more processors (multicore) in computers.
d.
All
What approach does java.util.concurrent.ForkJoinPool uses for managing tasks?
a.
Data modelling approach
b.
Observing approach
c.
Behavioural approach
d.
work-stealing approach
What is true about java.util.concurrent.RecursiveTask in thread concurrency in java?
a.
It provides
calculate
() for submitting a task but it does not return a result
b.
It provides compute() for submitting a task and returning a result
c.
It provides calculate() for submitting a task and returning a result
d.
It provides compute() for submitting a task but it does not return a result
What is valid about synchronized and java.util.concurrent.locks.ReentrantLock in thread concurrency in java
a.
synchronized Does not provide any fair locks.
b.
ReentrantLock provides fair lock
c.
ReentrantLock provides getQueueLength() method to return number of threads that may be waiting to acquire this lock.
d.
All
What is valid about call method of Callable interface in thread concurrency in java?
a.
call() method can only throw an exception if unable to calculate result.
b.
call() method returns computed result or throws an exception if unable to do so
c.
call() method returns computed result but cannot throw an exception if unable to do so
d.
call() method cannot return result
Which method can be used to find whether lock is held by current thread?
a.
findLockHold()
b.
isLockHeld()
c.
holdsLock()
d.
lockHold()
What is valid about java.util.concurrent.CountDownLatch in thread concurrency in java?
a.
java.util.concurrent.CountDownLatch can be used to launch event
b.
for completing wait in java.util.concurrent.CountDownLatch specified number of threads must call countDown() method
c.
java.util.concurrent.CountDownLatch can be awaited repeatedly
d.
None of these
What is valid about arrive() and arriveAndAwaitAdvance() method of java.util.concurrent.Phaser in thread concurrency in java?
a.
arrive() method of java.util.concurrent.Phaser does not cause current thread to wait for other registered threads to
complete
current phase
b.
arriveAndAwaitAdvance() method causes current thread to wait for other registered threads to completecurrent phase
c.
All
d.
None
Quiz 1 - Correct answers
MEDIUM
1) a
2) a
3) a
4) a
5) a
6) b
7) a
8) a
9) b
10) a
11) c
12) c
13) a
14) c
15) c
16) a
17) c
18) c
19) a
20) c
21) a
22) d
HARD
23) d
24) d
25) b
26) d
27) b
28) c
29) b
30) c
Go to TOP of the page
Thread Concurrency Java - MCQ set 2 (30 questions, 68 marks)
Q1 - Q22, 22 MEDIUM level difficulty questions 2 mark each. 2 * 22 = 44 marks
Lock is found in which package in thread concurrency in java?
a.
java.util.concurrent.locks
b.
java.util
c.
java.util.locks
d.
java.util.concurrent
Lock was introduced in which java version
a.
Java 5
b.
Java 6
c.
Java 7
d.
Java 8
Lock is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
ReentrantLock is found in which package in thread concurrency in java?
a.
java.util.concurrent.locks
b.
java.util
c.
java.util.locks
d.
java.util.concurrent
ReentrantLock was introduced in which java version
a.
Java 5
b.
Java 6
c.
Java 7
d.
Java 8
ReentrantLock is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
ReadWriteLock is found in which package in thread concurrency in java?
a.
java.util.concurrent.locks
b.
java.util
c.
java.util.locks
d.
java.util.concurrent
ReadWriteLock was introduced in which java version
a.
Java 5
b.
Java 6
c.
Java 7
d.
Java 8
ReadWriteLock is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
ReentrantReadWriteLock is found in which package in thread concurrency in java?
a.
java.util.concurrent.locks
b.
java.util
c.
java.util.locks
d.
java.util.concurrent
ReentrantReadWriteLock was introduced in which java version
a.
Java 5
b.
Java 6
c.
Java 7
d.
Java 8
ReentrantReadWriteLock is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
CountDownLatch is found in which package in thread concurrency in java?
a.
java.util.concurrent
b.
java.util
c.
java.io
d.
java.lang
CountDownLatch was introduced in which java version
a.
Java 5
b.
Java 6
c.
Java 7
d.
Java 8
CountDownLatch is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
CyclicBarrier is found in which package in thread concurrency in java?
a.
java.util.concurrent
b.
java.util
c.
java.io
d.
java.lang
CyclicBarrier was introduced in which java version
a.
Java 5
b.
Java 6
c.
Java 7
d.
Java 8
CyclicBarrier is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
Phaser is found in which package in thread concurrency in java?
a.
java.util.concurrent
b.
java.util
c.
java.io
d.
java.lang
Phaser was introduced in which java version
a.
Java 5
b.
Java 6
c.
Java 7
d.
Java 8
Phaser is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
Exchanger is found in which package in thread concurrency in java?
a.
java.util.concurrent
b.
java.util
c.
java.io
d.
java.lang
Q23 - Q30, 8 HARD level difficulty questions 3 mark each. 3 * 8 = 24 marks
What are important methods of java.util.concurrent.atomic.AtomicInteger
a.
get()
b.
set()
c.
getAndSet(int newValue)
d.
all()
What is valid about run method of java.lang.Runnable interface?
a.
run() method can only throw an exception if unable to calculate result.
b.
run() method returns computed result or throws an exception if unable to do so
c.
run() method does not return a result and can neither throw a checked exception
d.
run() method returns computed result but cannot throw an exception if unable to do so
What does CountDownLatch(int count) constructor specifies?
a.
CountDownLatch is initialized with given count.
b.
count specifies the number of events that must occur before latch is released.
c.
Once count reaches 0 latch is released.
d.
All of these
What happens in java.util.concurrent.CyclicBarrier class?
a.
2 or more threads wait for each other to reach a common barrier point.
b.
When all threads have reached common barrier point (i.e. when all threads have called await() method) all waiting threads are released
c.
When all threads have reached common barrier point (i.e. when all threads have called await() method) event can be triggered as well
d.
All
What is valid about java.util.concurrent.Phaser class?
a.
Phaser provides us flexibility of registering and deRegistering parties at any time
b.
Phaser allows us registering and deRegistering parties in constructor only
c.
Phaser can't be awaited repeatedly
d.
All
java.util.concurrent.Phaser provides which of the following for registering parties/thread?
a.
register() method
b.
bulkRegister(int parties) method
c.
constructor = Phaser(int parties)
d.
All
We could override onAdvance() method of java.util.concurrent.Phaser to?
a.
advance to previous phase
b.
register the parties/threads for next phase
c.
control number of phases which we want to execute.
d.
All
When Phaser is terminated?
a.
When calling arriveAndDeregister() method of Phaser has caused the number of registered parties to become 0.
b.
Termination can also be triggered when an onAdvance() method returns true.
c.
All
d.
None of these
Quiz 2 - Correct answers
MEDIUM
1) a
2) a
3) b
4) a
5) a
6) a
7) a
8) a
9) b
10) a
11) a
12) a
13) a
14) a
15) a
16) a
17) a
18) a
19) a
20) c
21) a
22) a
HARD
23) d
24) c
25) d
26) d
27) a
28) d
29) c
30) c
Go to TOP of the page
Thread Concurrency Java - MCQ set 3 (30 questions, 68 marks)
Q1 - Q22, 22 MEDIUM level difficulty questions 2 mark each. 2 * 22 = 44 marks
What is java.util.concurrent.semaphore class
a.
provides parallel programming
b.
cannot controls access to a shared resource
c.
controls access to a shared resource by using permits
d.
None
What are important methods provided by Semaphore in maintaining concurrency
a.
acquire()/release() methods
b.
conquer()/release() methods
c.
acquire()/drop() methods
d.
conquer()/drop() methods
Exchanger was introduced in which java version
a.
Java 5
b.
Java 6
c.
Java 7
d.
Java 8
Exchanger is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
Which concurrency class/Interface/framework uses Divide-and-conquer strategy?
a.
Semaphore
b.
Phaser
c.
CyclicBarrier
d.
Fork/Join framework
What is valid about Executor service framework in java
a.
creates thread
b.
starts threads
c.
manages whole life cycle of Threads.
d.
All
AtomicInteger is found in which package?
a.
java.util.concurrent.atomic
b.
java.util
c.
java.util.atomic
d.
java.util.concurrent
e.
It doesn't exists till Java 8
AtomicInteger was introduced in which java version
a.
Java 5
b.
Java 6
c.
Java 7
d.
Java 8
e.
It doesn't exists till Java 8
AtomicInteger is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
e.
It doesn't exists till Java 8
AtomicLong is found in which package?
a.
java.util.concurrent.atomic
b.
java.util
c.
java.util.atomic
d.
java.util.concurrent
e.
It doesn't exists till Java 8
AtomicLong was introduced in which java version
a.
Java 5
b.
Java 6
c.
Java 7
d.
Java 8
e.
It doesn't exists till Java 8
AtomicLong is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
e.
It doesn't exists till Java 8
AtomicDouble is found in which package?
a.
java.util.concurrent.atomic
b.
java.util
c.
java.util.atomic
d.
java.util.concurrent
e.
It doesn't exists till Java 8
AtomicDouble was introduced in which java version
a.
Java 5
b.
Java 6
c.
Java 7
d.
Java 8
e.
It doesn't exists till Java 8
AtomicDouble is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
e.
It doesn't exists till Java 8
AtomicBoolean is found in which package?
a.
java.util.concurrent.atomic
b.
java.util
c.
java.util.atomic
d.
java.util.concurrent
e.
It doesn't exists till Java 8
AtomicBoolean was introduced in which java version
a.
Java 5
b.
Java 6
c.
Java 7
d.
Java 8
e.
It doesn't exists till Java 8
AtomicBoolean is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
e.
It doesn't exists till Java 8
AtomicFloat is found in which package?
a.
java.util.concurrent.atomic
b.
java.util
c.
java.util.atomic
d.
java.util.concurrent
e.
It doesn't exists till Java 8
AtomicFloat was introduced in which java version
a.
Java 5
b.
Java 6
c.
Java 7
d.
Java 8
e.
It doesn't exists till Java 8
AtomicFloat is a class/interface/abstract class/other?
a.
Class
b.
Interface
c.
Abstract class
d.
Other
e.
It doesn't exists till Java 8
Which is valid statement
a.
Callable interface provides method for computing and returning result
b.
submit() method is defined in ExecutorService interface and does not return result of computation.
c.
execute() method is defined in Executor interface.
d.
All
Q23 - Q30, 8 HARD level difficulty questions 3 mark each. 3 * 8 = 24 marks
Difference between java.util.concurrent.Callable and java.lang.Runnable
a.
Class implementing Callable interface must override call() method. call() method returns computed result or throws an exception if unable to do so.
b.
Class implementing Runnable interface must override run() method.
c.
A Runnable does not return a result and can neither throw a checked exception.
d.
All
which of these class provide support for atomic operations till java 8?
a.
AtomicString
b.
AtomicDouble
c.
AtomicFloat
d.
AtomicBoolean
What is maximum number of parties that could be registered with phaser at a time ?
a.
6500
b.
65535
c.
1500
d.
100
What is java.util.concurrent.Exchanger class?
a.
Exchanger enables two methods to exchange their data between each other
b.
Exchanger enables remote method invocation RMI
c.
Exchanger enables two threads to exchange their data between each other
d.
What are key method of Lock interface?
a.
lock()/unLock() methods
b.
getLock()/ setLock() methods
c.
setLock()/getUnLock() methods
d.
None
What will be output of following program -
a.
Thread-2 is Waiting to acquire lock Thread-1 is Waiting to acquire lock Thread-1 has acquired lock. Thread-2 didn't got lock.
b.
Thread-1 is Waiting to acquire lock Thread-2 is Waiting to acquire lock Thread-1 has acquired lock. Thread-2 didn't got lock.
c.
Thread-1 is Waiting to acquire lock Thread-1 has acquired lock. Thread-2 is Waiting to acquire lock Thread-2 didn't got lock.
d.
None
What is valid about java.util.concurrent.CyclicBarrier?
a.
CyclicBarrier can't be used to trigger event
b.
CyclicBarrier can be awaited repeatedly
c.
CyclicBarrier can't be awaited repeatedly
d.
None
What will be output of following code -
a.
parentPhaser isTerminated : true
childPhaser isTerminated : true
--childPhaser has called arriveAndDeregister()--
parentPhaser isTerminated : false
childPhaser isTerminated : true
b.
parentPhaser isTerminated : false
childPhaser isTerminated : true
--childPhaser has called arriveAndDeregister()--
parentPhaser isTerminated : true
childPhaser isTerminated : true
c.
parentPhaser isTerminated : false
childPhaser isTerminated : false
--childPhaser has called arriveAndDeregister()--
parentPhaser isTerminated : true
childPhaser isTerminated : true
d.
parentPhaser isTerminated : true
childPhaser isTerminated : false
--childPhaser has called arriveAndDeregister()--
parentPhaser isTerminated : false
childPhaser isTerminated : true
Quiz 3 - Correct answers
MEDIUM
1) c
2) a
3) a
4) a
5) d
6) d
7) a
8) a
9) a
10) a
11) a
12) a
13) e
14) e
15) e
16) a
17) a
18) a
19) e
20) e
21) e
22) d
HARD
23) d
24) d
25) b
26) c
27) a
28) b
29) b
30) c
1 comment:
prasad articles
18 March 2019 at 04:39
nicwe post
Download bigo live app for black berry os
Reply
Delete
Replies
Reply
Add comment
Load more...
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
nicwe post Download bigo live app for black berry os
ReplyDelete