SlideShare a Scribd company logo
Quiz	
Fun way to learn more
Ques%on		
You’ve	wri/en	an	applica%on	for	processing	tasks.	In	this	applica%on,	
you’ve	separated	the	cri%cal	or	urgent	tasks	from	the	ones	that	are	not	
cri%cal	or	urgent.	You’ve	assigned	high	priority	to	cri%cal	or	urgent	tasks.	
	
In	this	applica%on,	you	find	that	the	tasks	that	are	not	cri%cal	or	urgent	
are	the	ones	that	keep	wai%ng	for	an	unusually	long	%me.	Since	cri%cal	or	
urgent	tasks	are	high	priority,	they	run	most	of	the	%me.	Which	one	of	
the	following	mul%-threading	problems	correctly	describes	this	situa%on?	
	
A.	Deadlock	
B.	Starva1on	
C.	Livelock	
D.	Race	condi1on
Answer	
You’ve	wri;en	an	applica1on	for	processing	tasks.	In	this	applica1on,	
you’ve	separated	the	cri1cal	or	urgent	tasks	from	the	ones	that	are	not	
cri1cal	or	urgent.	You’ve	assigned	high	priority	to	cri1cal	or	urgent	tasks.	
	
In	this	applica1on,	you	find	that	the	tasks	that	are	not	cri1cal	or	urgent	are	
the	ones	that	keep	wai1ng	for	an	unusually	long	1me.	Since	cri1cal	or	
urgent	tasks	are	high	priority,	they	run	most	of	the	1me.	Which	one	of	the	
following	mul1-threading	problems	correctly	describes	this	situa1on?	
	
A.	Deadlock	
B.	Starva%on	
C.	Livelock	
D.	Race	condi1on
Explana%on	
B	.	Starva1on	
The	situa1on	in	which	low-priority	threads	keep	wai1ng	
for	a	long	1me	to	acquire	the	lock	and	execute	the	code	
in	cri1cal	sec1ons	is	known	as	starva1on.	
	
	
	
Starva%on	
Starva&on	describes	a	situa1on	where	a	thread	is	unable	to	gain	regular	access	to	shared	
resources	and	is	unable	to	make	progress.	This	happens	when	shared	resources	are	made	
unavailable	for	long	periods	by	"greedy"	threads.		
	
Livelock	
A	thread	oNen	acts	in	response	to	the	ac1on	of	another	thread.	If	the	other	thread's	
ac1on	is	also	a	response	to	the	ac1on	of	another	thread,	then	livelock	may	result.	As	with	
deadlock,	livelocked	threads	are	unable	to	make	further	progress.	However,	the	threads	
are	not	blocked	—	they	are	simply	too	busy	responding	to	each	other	to	resume	work.	
This	is	comparable	to	two	people	a;emp1ng	to	pass	each	other	in	a	corridor:	Alphonse	
moves	to	his	leN	to	let	Gaston	pass,	while	Gaston	moves	to	his	right	to	let	Alphonse	pass.	
Seeing	that	they	are	s1ll	blocking	each	other,	Alphone	moves	to	his	right,	while	Gaston	
moves	to	his	leN.	They're	s1ll	blocking	each	other,	so...	
Source:	docs.oracle.com
Ques%on		
Which	of	the	following	two	defini%ons	of	Sync	(when		
compiled	in	separate	files)	will	compile	without	errors?	
	
A.			
class	Sync	{	
				public	synchronized	void	foo()	{}	
}	
B.		
abstract	class	Sync	{	
				public	synchronized	void	foo()	{}	
}	
C.		
abstract	class	Sync	{	
				public	abstract	synchronized	void	foo();	
}	
D.		
interface	Sync	{	
					public	synchronized	void	foo();	
}
Answer	
Which	of	the	following	two	defini%ons	of	Sync	(when		
compiled	in	separate	files)	will	compile	without	errors?	
	
A.			
class	Sync	{	
				public	synchronized	void	foo()	{}	
}	
B.		
abstract	class	Sync	{	
				public	synchronized	void	foo()	{}	
}	
C.		
abstract	class	Sync	{	
				public	abstract	synchronized	void	foo();	
}	
D.		
interface	Sync	{	
					public	synchronized	void	foo();	
}
Explana%on	
Abstract	methods	(in	abstract	classes	or	interfaces)	
cannot	be	declared	synchronized	,	hence	the	op1ons	C	
and	D	are	incorrect.
Ques%on		
Which	ONE	of	the	following	op%ons	correctly	makes	use	of		
Callable	that	will	compile	without	any	errors?	
	
	
	
A.		
import	java.u1l.concurrent.Callable;	
class	CallableTask	implements	Callable	{	
				public	int	call()	{	
								System.out.println("In	Callable.call()");	
								return	0;	
				}	
}	
B.		
import	java.u1l.concurrent.Callable;	
class	CallableTask	extends	Callable	{	
				public	Integer	call()	{	
								System.out.println("In	Callable.call()");	
								return	0;	
				}	
}	
C.		
import	java.u1l.concurrent.Callable;	
class	CallableTask	implements	Callable<Integer>	
{	
				public	Integer	call()	{	
							System.out.println("In	Callable.call()");	
							return	0;	
				}	
}	
D.		
import	java.u1l.concurrent.Callable;	
class	CallableTask	implements	Callable<Integer>	{	
				public	void	call(Integer	i)	{	
								System.out.println("In	Callable.call(i)");	
				}	
}
Answer	
Which	one	of	the	following	op1ons	correctly	makes	use	of		
Callable	that	will	compile	without	any	errors?	
	
	
	
A.		
import	java.u1l.concurrent.Callable;	
class	CallableTask	implements	Callable	{	
				public	int	call()	{	
								System.out.println("In	Callable.call()");	
								return	0;	
				}	
}	
B.		
import	java.u1l.concurrent.Callable;	
class	CallableTask	extends	Callable	{	
				public	Integer	call()	{	
								System.out.println("In	Callable.call()");	
								return	0;	
				}	
}	
C.		
import	java.u%l.concurrent.Callable;	
class	CallableTask	implements	
Callable<Integer>	{	
				public	Integer	call()	{	
							System.out.println("In	Callable.call()");	
							return	0;	
				}	
}	
D.		
import	java.u1l.concurrent.Callable;	
class	CallableTask	implements	Callable<Integer>	{	
				public	void	call(Integer	i)	{	
								System.out.println("In	Callable.call(i)");	
				}	
}
Explana%on	
C.		
The	Callable	interface	is	defined	as	follows:	
public	interface	Callable<V>	{	
							V	call()	throws	Excep1on;	
}	
	
In	op1on	A),	the	call()	method	has	the	return	type	int	,	which	is	incompa1ble	
with	the	return	type	expected	for	overriding	the	call	method	and	so	will	not	
compile.	
	
In	op1on	B),	the	extends	keyword	is	used,	which	will	result	in	a	compiler	(since	
Callable	is	an	interface,	the	implements	keyword	should	be	used).	
	
In	op1on	D),	the	return	type	of	call()	is	void	and	the	call()	method	also	takes	a	
parameter	of	type	Integer	.	Hence,	the	method	declared	in	the	interface	Integer	
call()	remains	unimplemented	in	the	CallableTask	class,	so	the	program	will	not	
compile.
Ques%on		
Here	is	a	class	named	PingPong	that	extends	the	Thread	class.	Which	ONE	of	the	
following	PingPong	class	implementa%ons	correctly	prints	“ping”	from	the	
worker	thread	and	then	prints	“pong”	from	the	main	thread?	
A.		
					public	sta1c	void	main(String	[]args)	{	
									Thread	pingPong	=	new	PingPong();	
									System.out.print("pong");	
						}	
}	
B.			
				public	sta1c	void	main(String	[]args)	{	
									Thread	pingPong	=	new	PingPong();	
									pingPong.run();	
									System.out.print("pong");	
				}	
}	
C.		
				public	sta1c	void	main(String	[]args)	{	
									Thread	pingPong	=	new	PingPong();	
									pingPong.start();	
									System.out.println("pong");	
					}	
}	
D.		
				public	sta1c	void	main(String	[]args)	throws				
InterruptedExcep1on{	
					Thread	pingPong	=	new	PingPong();	
					pingPong.start();	
					pingPong.join();	
					System.out.println("pong");	
				}	
}	
class	PingPong	extends	Thread	{	
				public	void	run()	{	
								System.out.println("ping	");	
				}	
			//	ONE	OF	THE	OPTIONS	HERE
Answer		
Here	is	a	class	named	PingPong	that	extends	the	Thread	class.	Which	ONE	of	the	
following	PingPong	class	implementa%ons	correctly	prints	“ping”	from	the	
worker	thread	and	then	prints	“pong”	from	the	main	thread?	
A.		
					public	sta1c	void	main(String	[]args)	{	
									Thread	pingPong	=	new	PingPong();	
									System.out.print("pong");	
						}	
}	
B.			
				public	sta1c	void	main(String	[]args)	{	
									Thread	pingPong	=	new	PingPong();	
									pingPong.run();	
									System.out.print("pong");	
				}	
}	
C.		
				public	sta1c	void	main(String	[]args)	{	
									Thread	pingPong	=	new	PingPong();	
									pingPong.start();	
									System.out.println("pong");	
					}	
}	
D.		
				public	sta%c	void	main(String	[]args)	throws				
InterruptedExcep%on{	
					Thread	pingPong	=	new	PingPong();	
					pingPong.start();	
					pingPong.join();	
					System.out.println("pong");	
				}	
}	
class	PingPong	extends	Thread	{	
				public	void	run()	{	
								System.out.println("ping	");	
				}	
			//	ONE	OF	THE	OPTIONS	HERE
Explana%on	
D	.	
The	main	thread	creates	the	worker	thread	and	waits	for	it	to	
complete	(which	prints	“ping”).	ANer	that	it	prints	“pong”.	So,	
this	implementa1on	correctly	prints	“ping	pong”.	
	
Why	are	the	other	op1ons	wrong?	
A.	The	main()	method	creates	the	worker	thread,	but	doesn’t	start	it.	
So,	the	code	given	in	this	op1on	only	prints	“pong”.	
	
B.	The	program	always	prints	“ping	pong”,	but	it	is	misleading.	The	
code	in	this	op1on	directly	calls	the	run()	method	instead	of	calling	
the	start()	method.	So,	this	is	a	single	threaded	program:	both	“ping”	
and	“pong”	are	printed	from	the	main	thread.	
	
C.	The	main	thread	and	the	worker	thread	execute	independently	
without	any	coordina1on.	(Note	that	it	does	not	have	a	call	to	join()	
in	the	main	method.)	So,	depending	on	which	thread	is	scheduled	
first,	you	can	get	“ping	pong”	or	“pong	ping”	printed.
Ques%on		
Choose	the	correct	op%on	based	on	this	program:	
	
class	COWArrayListTest	{	
				public	sta%c	void	main(String	[]args)	{	
							ArrayList<Integer>	aList	=	
	 		new	CopyOnWriteArrayList<Integer>();	//	LINE	A	
							aList.addAll(Arrays.asList(10,	20,	30,	40));	
							System.out.println(aList);	
				}	
}	
	
A.	When	executed	the	program	prints	the	following:	[10,	20,	30,	40].	
B.	When	executed	the	program	prints	the	following:	
CopyOnWriteArrayList.class	.	
C.	The	program	does	not	compile	and	results	in	a	compiler	error	in	line	
marked	with	comment	LINE	A	.	
D.	When	executed	the	program	throws	a	run1me	excep1on	
ConcurrentModifica1onExcep1on	.
Answer	
Choose	the	correct	op%on	based	on	this	program:	
	
class	COWArrayListTest	{	
				public	sta1c	void	main(String	[]args)	{	
							ArrayList<Integer>	aList	=	
	 		new	CopyOnWriteArrayList<Integer>();	//	LINE	A	
							aList.addAll(Arrays.asList(10,	20,	30,	40));	
							System.out.println(aList);	
				}	
}	
	
A.	When	executed	the	program	prints	the	following:	[10,	20,	30,	40].	
B.	When	executed	the	program	prints	the	following:	
CopyOnWriteArrayList.class	.	
C.	The	program	does	not	compile	and	results	in	a	compiler	error	in	line	
marked	with	comment	LINE	A	.	
D.	When	executed	the	program	throws	a	run1me	excep1on	
ConcurrentModifica1onExcep1on	.
Explana%on	
C	.	The	program	does	not	compile	and	results	in	a	compiler	
error	in	the	line	marked	with	comment	LINE	A.	
	
The	class	CopyOnWriteArrayList	does	not	inherit	from	
ArrayList	,	so	an	a;empt	to	assign	a	CopyOnWriteArrayList	to	
an	ArrayList	reference	will	result	in	a	compiler	error.	Note	that	
the	ArrayList	suffix	in	the	class	named	CopyOnWriteArrayList	
could	be	misleading	as	these	two	classes	do	not	share	anIS-A	
rela1onship.
Ques%on		
What	will	this	code	segment	print?	
	
List<Integer>	ints	=	Arrays.asList(1,	2,	3,	4,	5);	
				System.out.println(ints.parallelStream()	
																																														.filter(i	->	(i	%	2)	==	0).sequenEal()	
																																														.isParallel());	
	
A.	Prints:	2	4	
B.	Prints:	false	
C.	Prints:	true	
D.	Cannot	determine	the	output	because	the	program	has	non-
determinis1c	behaviour
Answer		
What	will	this	code	segment	print?	
	
List<Integer>	ints	=	Arrays.asList(1,	2,	3,	4,	5);	
				System.out.println(ints.parallelStream()	
																																														.filter(i	->	(i	%	2)	==	0).sequenEal()	
																																														.isParallel());	
	
A.	Prints:	2	4	
B.	Prints:	false	
C.	Prints:	true	
D.	Cannot	determine	the	output	because	the	program	has	non-
determinis1c	behaviour
Explana%on	
B.	Prints	false	
	
Though	the	created	stream	is	a	parallel	stream,	the	
call	to	the	sequen1al()	method	has	made	the	stream	
sequen1al.	Hence,	the	call	isParallel()	prints	false	.
Ques%on		
Which	one	of	the	following	methods	return	a	Future	object?	
	
A.	The	overloaded	replace()	methods	declared	in	the	ConcurrentMap	
interface	
B.	The	newThread()	method	declared	in	the	ThreadFactory	interface	
C.	The	overloaded	submit()	methods	declared	in	the	ExecutorService	
interface	
D.	The	call()	method	declared	in	the	Callable	interface
Answer	
Which	one	of	the	following	methods	return	a	Future	object?	
	
A.	The	overloaded	replace()	methods	declared	in	the	ConcurrentMap	
interface	
B.	The	newThread()	method	declared	in	the	ThreadFactory	interface	
C.	The	overloaded	submit()	methods	declared	in	the	ExecutorService	
interface	
D.	The	call()	method	declared	in	the	Callable	interface
Explana%on	
C	.	The	overloaded	submit()	methods	declared	in	
ExecutorService	interface.	The	ExecutorService	interface	
extends	the	Executor	interface	and	provides	services	such	as	
termina1on	of	threads	and	produc1on	of	Future	objects.	Some	
tasks	may	take	considerable	execu1on	1me	
to	complete.	So,	when	you	submit	a	task	to	the	executor	
service,	you	get	a	Future	object.	
	
A.	The	overloaded	replace()	methods	declared	in	the	ConcurrentMap	
interface	remove	an	element	from	the	map	and	return	the	success	
status	(a	Boolean	value)	or	the	removed	value.	
	
B.	The	new	Thread()	is	the	only	method	declared	in	the	
ThreadFactory	interface	and	it	returns	a	Thread	object	as	the	return	
value	
	
D.	The	call()	method	declared	in	Callable	interface	returns	the	result	
of	the	task	it	executed.
Ques%on		
In	your	applica%on,	there	is	a	producer	component	that	keeps	adding	
new	items	to	a	fixed-size	queue;	the	consumer	component	fetches	
items	from	that	queue.	If	the	queue	is	full,	the	producer	has	to	wait	
for	items	to	be	fetched;	if	the	queue	is	empty,	the	consumer	has	to	
wait	for	items	to	be	added.	
Which	one	of	the	following	u%li%es	is	suitable	for	synchronizing	the	
common	queue	for	concurrent	use	by	a	producer	and	consumer?	
	
A.	ForkJoinPool	
B.	Future	
C.	Semaphore	
D.	TimeUnit
Answer	
In	your	applica1on,	there	is	a	producer	component	that	keeps	adding	
new	items	to	a	fixed-size	queue;	the	consumer	component	fetches	
items	from	that	queue.	If	the	queue	is	full,	the	producer	has	to	wait	for	
items	to	be	fetched;	if	the	queue	is	empty,	the	consumer	has	to	wait	
for	items	to	be	added.	
Which	one	of	the	following	u1li1es	is	suitable	for	synchronizing	the	
common	queue	for	concurrent	use	by	a	producer	and	consumer?	
	
A.	ForkJoinPool	
B.	Future	
C.	Semaphore	
D.	TimeUnit
Explana%on	
C.	Semaphore	
	
The	ques1on	is	a	classic	producer–consumer	problem	that	can	be	
solved	by	using	semaphores.	The	objects	of	the	synchronizer	class	
java.u1l.concurrent.Semaphore	can	be	used	to	guard	the	common	
queue	so	that	the	producer	and	consumer	can	synchronize	their	
access	to	the	queue.	Of	the	given	op1ons,	semaphore	is	the	only	
synchronizer	;	other	op1ons	are	unrelated	to	providing	
synchronized	access	to	a	queue.	
	
A.  ForkJoinPool	provides	help	in	running	a	ForkJoinTask	in	the	context	of	
the	Fork/Join	framework.		
B.	Future	represents	the	result	of	an	asynchronous	computa1on	whose	
result	will	be	“available	in	the	future	once	the	computa1on	is	complete.”		
	
D.	TimeUnit	is	an	enumera1on	that	provides	support	for	different	1me	
units	such	as	milliseconds,	seconds,	and	days.
Ques%on		
What	will	this	code	segment	print?	
	
class	StringConcatenator	{	
				public	sta%c	String	result	=	"";	
				public	sta%c	void	concatStr(String	str)	{	
								result	=	result	+	"	"	+	str;	
				}	
}	
	
class	StringSplitAndConcatenate	{	
				public	sta%c	void	main(String	[]args)	{	
								String	words[]	=	"the	quick	brown	fox	jumps	over	the	lazy	dog".split("	");	
								Arrays.stream(words).parallel().forEach(StringConcatenator::concatStr);	
								System.out.println(StringConcatenator.result);	
				}	
}	
	
A.	over	jumps	lazy	dog	the	brown	fox	quick	the	
B.	the	quick	brown	fox	jumps	over	the	lazy	dog	
C.	Prints	each	word	in	new	line	
D.	Cannot	predict	output
Answer	
What	will	this	code	segment	print?	
	
class	StringConcatenator	{	
				public	sta1c	String	result	=	"";	
				public	sta1c	void	concatStr(String	str)	{	
								result	=	result	+	"	"	+	str;	
				}	
}	
	
class	StringSplitAndConcatenate	{	
				public	sta1c	void	main(String	[]args)	{	
								String	words[]	=	"the	quick	brown	fox	jumps	over	the	lazy	dog".split("	");	
								Arrays.stream(words).parallel().forEach(StringConcatenator::concatStr);	
								System.out.println(StringConcatenator.result);	
				}	
}	
	
A.	over	jumps	lazy	dog	the	brown	fox	quick	the	
B.	the	quick	brown	fox	jumps	over	the	lazy	dog	
C.	Prints	each	word	in	new	line	
D.	Cannot	predict	output
Explana%on	
D.	Cannot	predict	output	
	
When	the	stream	is	parallel,	the	task	is	split	into	
mul1ple	sub-tasks	and	different	threads	execute	it.	
The	calls	to	forEach(StringConcatenator::concatStr)	
now	access	the	globally	accessible	variable	result	
in	StringConcatenator	class.	Hence	it	results	in	garbled	
output.
Ques%on		
What	is	the	expected	output	of	this	code	segment	when	invoked	as	follows:	
java	-ea	AtomicIntegerTest	
	
sta%c	AtomicInteger	ai	=	new	AtomicInteger(10);	
public	sta%c	void	main(String	[]args)	{	
				ai.incrementAndGet();	
				ai.getAndDecrement();	
				ai.compareAndSet(10,	11);	
				assert	(ai.intValue()	%	2)	==	0;	
				System.out.println(ai);	
}	
	
A.	Prints:	10	11	
B.	Prints:	10	
C.	It	crashes	by	throwing	an	Asser1onError	
D.	Prints:	9
Answer		
What	is	the	expected	output	of	this	code	segment	when	invoked	as	follows:	
java	-ea	AtomicIntegerTest	
	
sta%c	AtomicInteger	ai	=	new	AtomicInteger(10);	
public	sta%c	void	main(String	[]args)	{	
				ai.incrementAndGet();	
				ai.getAndDecrement();	
				ai.compareAndSet(10,	11);	
				assert	(ai.intValue()	%	2)	==	0;	
				System.out.println(ai);	
}	
	
A.	Prints:	10	11	
B.	Prints:	10	
C.	It	crashes	by	throwing	an	Asser%onError	
D.	Prints:	9
Explana%on	
C.  It	crashes	throwing	an	Asser1onError	.	
The	ini1al	value	of	AtomicInteger	is	10.	Its	value	is	
incremented	by	1	aNer	calling	incrementAndGet	().		
	
ANer	that,	its	value	is	decremented	by	1	aNer	calling	
getAndDecrement	(	).		
	
The	method	compareAndSet	(10,	11)	checks	if	the	
current	value	is	10,	and	if	so	sets	the	atomic	integer	
variable	to	value	11.		
	
Since	the	assert	statement	checks	if	the	atomic	
integer	value	%	2	is	zero	(that	is,	checks	if	it	is	an	even	
number),	the	assert	fails	and	the	program	results	in	an	
Asser1onError	.
Ques%on		
Consider	that	you	are	developing	an	cards	game	where	a	person	starts	the	
game	and	waits	for	the	other	players	to	join.	Minimum	4	players	are	
required	to	start	the	game	and	as	soon	as	all	the	players	are	available	the	
game	has	to	get	started.	For	developing	such	kind	of	game	applica%on	which	
of	the	following	synchroniza%on	technique	would	be	ideal:	
	
A.	Semaphore	
B.	Exchanger	
C.	Runnable	
D.	CyclicBarrier
Answer	
Consider	that	you	are	developing	an	cards	game	where	a	person	starts	the	
game	and	waits	for	the	other	players	to	join.	Minimum	4	players	are	
required	to	start	the	game	and	as	soon	as	all	the	players	are	available	the	
game	has	to	get	started.	For	developing	such	kind	of	game	applica%on	which	
of	the	following	synchroniza%on	technique	would	be	ideal:	
	
A.	Semaphore	
B.	Exchanger	
C.	Runnable	
D.	CyclicBarrier
Explana%on	
D.	CyclicBarrier		
	
CyclicBarrier	helps	provide	a	synchroniza1on	point	
where	threads	may	need	to	wait	at	a	predefined	
execu1on	point	un1l	all	other	threads	reach	that	
point.	
	
A.	A	Semaphore	controls	access	to	shared	resources.	
A	semaphore	maintains	a	counter	to	specify	number	
of	resources	that	the	semaphore	controls	
B.		The	Exchanger	class	is	meant	for	exchanging	data	
between	two	threads.	This	class	is	useful	when	two	
threads	need	to	synchronize	between	each	other	and	
con1nuously	
exchange	data.	
C.	Runnable		is	an	interface	used	in	crea1ng	threads
Ques%on		
Consider	the	following	program	and	choose	the	correct	op%on	describing	its	
behavior	
	
class	PingPong	extends	Thread	{	
				public	void	run()	{	
								System.out.print("ping	");	
								throw	new	IllegalStateExcep%on();	
				}	
				public	sta%c	void	main(String	[]args)	throws	InterruptedExcep%on	{	
								Thread	pingPong	=	new	PingPong();	
								pingPong.start();	
								System.out.print("pong");	
				}	
}	
	
	
A.  This	program	results	in	a	compiler	error.	
B.  Prints	the	ping	pong	and	excep1on	in	any	order	
C.  This	program	throws	a	run1me	error.	
D.  Prints	pong	ping
Answer	
Consider	the	following	program	and	choose	the	correct	op%on	describing	its	
behavior	
	
class	PingPong	extends	Thread	{	
				public	void	run()	{	
								System.out.print("ping	");	
								throw	new	IllegalStateExcep1on();	
				}	
				public	sta1c	void	main(String	[]args)	throws	InterruptedExcep1on	{	
								Thread	pingPong	=	new	PingPong();	
								pingPong.start();	
								System.out.print("pong");	
				}	
}	
	
	
A.  This	program	results	in	a	compiler	error.	
B.  Prints	the	ping	pong	and	excep%on	in	any	order	
C.  This	program	throws	a	run1me	error.	
D.  Prints	pong	ping
Explana%on	
B.	Prints	the	ping	pong	and	excep1on	in	any	order	
	
The	programs	executes	fine	and	the	exact	output	
cannot	be	predicted	as	the	main	thread	and	the	
worker	thread	execute	independently	without	any	
coordina1on.
Upcoming	Workshops/Bootcamps	
•  SOLID	Principles	and	Design	Pa;erns	–	Aug	27th	
•  MicrosoN	Azure	Bootcamp	–	Aug	27th	
•  Modern	SoNware	Architecture	–	Sep	10th	
	
Please	visit	CodeOps.tech		for	more	details	such	as	
agenda/cost/trainer	and	registra1on.	
OCP	Java:	h;p://ocpjava.wordpress.com
Tech	talks	
q Tech	talks	are	for	knowledge	sharing	-	so	there	is	no	cost	
associated	with	it	
q We	usually	share	the	presenta1on	&	suppor1ng	material	to	
the	par1cipants	aNer	the	tech	talk	
q Dura1on	of	the	tech	talk	would	be	for	1	hour	and	will	be	
given	at	your	office	premises	
q Topics	on	which	we	offer	tech	talks	can	be	found	here	
Tech	Talk	Topics	
q We	also	offer	free	workshop	on	Introduc1on	to	Docker	
which	will	be	a	hands-on	session
Meetups	
•  Core-Java-Meetup-Bangalore		
•  SoNware-CraNsmanship-Bangalore	–	20th	July	@Ginserv	
•  Container-Developers-Meetup	-	20th	Aug	@Avaya		
•  CloudOps-Meetup-Bangalore	-	20th	Aug	@Avaya	
•  JavaScript-Meetup-Bangalore	-	20th	Aug		
•  Technical-Writers-Meetup-Bangalore	–	25th	Sep	
•  SoNware	Architects	Bangalore	–	1st	Oct	@Prowareness	
•  Bangalore-SDN-IoT-NetworkVirtualiza1on-Enthusiasts	
	
ganesh@codeops.tech @GSamarthyam
www.codeops.tech slideshare.net/sgganesh
+91 98801 64463 bit.ly/sgganesh
❖ Programming examples are
from our book:
❖ Oracle Certified
Professional Java SE 8
Programmer Exam 1Z0-809:
A Comprehensive OCPJP 8
Certification Guide, S.G.
Ganesh, Hari Kiran Kumar,
Tushar Sharma, Apress, 2016.
❖ Website: ocpjava.wordpress.com
Meetups	
•  Core-Java-Meetup-Bangalore		
•  SoNware-CraNsmanship-Bangalore	–	20th	July	@Ginserv	
•  Container-Developers-Meetup	-	20th	Aug	@Avaya		
•  CloudOps-Meetup-Bangalore	-	20th	Aug	@Avaya	
•  JavaScript-Meetup-Bangalore	-	20th	Aug		
•  Technical-Writers-Meetup-Bangalore	–	25th	Sep	
•  SoNware	Architects	Bangalore	–	1st	Oct	@Prowareness	
•  Bangalore-SDN-IoT-NetworkVirtualiza1on-Enthusiasts	
	
ganesh@codeops.tech @GSamarthyam
www.codeops.tech slideshare.net/sgganesh
+91 98801 64463 bit.ly/sgganesh

More Related Content

PPTX
clean code book summary - uncle bob - English version
PDF
Typescript in React: HOW & WHY?
PDF
Clean code
PPTX
Intro to React
PPTX
Technical aptitude Test 1 CSE
PDF
Integration testing with spring @snow one
PDF
Solid Principles
PPT
SOLID Design Principles
clean code book summary - uncle bob - English version
Typescript in React: HOW & WHY?
Clean code
Intro to React
Technical aptitude Test 1 CSE
Integration testing with spring @snow one
Solid Principles
SOLID Design Principles

What's hot (20)

PDF
Keeping Swift Apps Small
PDF
Understanding Reactive Programming
PDF
Semana 2 Clases y Objetos en Java
PPTX
React-JS Component Life-cycle Methods
PPTX
React + Redux Introduction
PDF
Microservices with Java, Spring Boot and Spring Cloud
PPTX
Spring beans
PDF
REST APIs with Spring
PPTX
C# Async Await
PPTX
Spring boot
PDF
Spring Framework - Core
PPTX
Clean code
PDF
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...
ODP
Clean code
PDF
React new features and intro to Hooks
PDF
Functional Core and Imperative Shell - Game of Life Example - Haskell and Scala
PDF
C multiple choice questions and answers pdf
PDF
Clean code
PDF
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
PDF
React and redux
Keeping Swift Apps Small
Understanding Reactive Programming
Semana 2 Clases y Objetos en Java
React-JS Component Life-cycle Methods
React + Redux Introduction
Microservices with Java, Spring Boot and Spring Cloud
Spring beans
REST APIs with Spring
C# Async Await
Spring boot
Spring Framework - Core
Clean code
Algebraic Data Types for Data Oriented Programming - From Haskell and Scala t...
Clean code
React new features and intro to Hooks
Functional Core and Imperative Shell - Game of Life Example - Haskell and Scala
C multiple choice questions and answers pdf
Clean code
Sum and Product Types - The Fruit Salad & Fruit Snack Example - From F# to Ha...
React and redux
Ad

Similar to Java Concurrency - Quiz Questions (20)

PDF
The Semaphore and Deadlock concept -os.pdf
PDF
OPERATING SYSTEM deadlock prevention techniques
PPT
Process Synchronization And Deadlocks
PPT
Deadlock in operating systems
PPTX
Deadlock _Classic problems.pptx
PPT
Deadlocks.ppt
PPTX
4.3 Deadlock [Autosaved].pptx
PPT
Deadlocks dhsidhcc ISIxnac bdbckjncmzczjkbc
PPTX
Ch 4 deadlock
PPTX
operating system memory management with example
PPTX
OS Unit 3.pptx
PPTX
OS K.Nishitha presentation on dead locks .pptx
PPT
Os6 2
PPTX
deadlock and starvation resources allocation.pptx
PPTX
Deadlock iOS topic ppt which goes deep into the deadlock.pptx
PPTX
3.6 Deadlock-operating system unit 3.pptx
PDF
Improved Deadlock Prevention Algorithms in Distributed Systems
PPTX
Cs problem [repaired]
PPTX
9-Operating Systems -Synchronization, interprocess communication, deadlock.pptx
PPT
06-Deadlocks.ppt
The Semaphore and Deadlock concept -os.pdf
OPERATING SYSTEM deadlock prevention techniques
Process Synchronization And Deadlocks
Deadlock in operating systems
Deadlock _Classic problems.pptx
Deadlocks.ppt
4.3 Deadlock [Autosaved].pptx
Deadlocks dhsidhcc ISIxnac bdbckjncmzczjkbc
Ch 4 deadlock
operating system memory management with example
OS Unit 3.pptx
OS K.Nishitha presentation on dead locks .pptx
Os6 2
deadlock and starvation resources allocation.pptx
Deadlock iOS topic ppt which goes deep into the deadlock.pptx
3.6 Deadlock-operating system unit 3.pptx
Improved Deadlock Prevention Algorithms in Distributed Systems
Cs problem [repaired]
9-Operating Systems -Synchronization, interprocess communication, deadlock.pptx
06-Deadlocks.ppt
Ad

More from Ganesh Samarthyam (20)

PDF
Wonders of the Sea
PDF
Animals - for kids
PDF
Applying Refactoring Tools in Practice
PDF
CFP - 1st Workshop on “AI Meets Blockchain”
PDF
Great Coding Skills Aren't Enough
PDF
College Project - Java Disassembler - Description
PDF
Coding Guidelines - Crafting Clean Code
PDF
Design Patterns - Compiler Case Study - Hands-on Examples
PDF
Bangalore Container Conference 2017 - Brief Presentation
PDF
Bangalore Container Conference 2017 - Poster
PDF
Software Design in Practice (with Java examples)
PDF
OO Design and Design Patterns in C++
PDF
Bangalore Container Conference 2017 - Sponsorship Deck
PDF
Let's Go: Introduction to Google's Go Programming Language
PPT
Google's Go Programming Language - Introduction
PDF
Java Generics - Quiz Questions
PDF
Java Generics - by Example
PDF
Software Architecture - Quiz Questions
PDF
Docker by Example - Quiz
PDF
Core Java: Best practices and bytecodes quiz
Wonders of the Sea
Animals - for kids
Applying Refactoring Tools in Practice
CFP - 1st Workshop on “AI Meets Blockchain”
Great Coding Skills Aren't Enough
College Project - Java Disassembler - Description
Coding Guidelines - Crafting Clean Code
Design Patterns - Compiler Case Study - Hands-on Examples
Bangalore Container Conference 2017 - Brief Presentation
Bangalore Container Conference 2017 - Poster
Software Design in Practice (with Java examples)
OO Design and Design Patterns in C++
Bangalore Container Conference 2017 - Sponsorship Deck
Let's Go: Introduction to Google's Go Programming Language
Google's Go Programming Language - Introduction
Java Generics - Quiz Questions
Java Generics - by Example
Software Architecture - Quiz Questions
Docker by Example - Quiz
Core Java: Best practices and bytecodes quiz

Recently uploaded (20)

PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
How to Confidently Manage Project Budgets
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
A REACT POMODORO TIMER WEB APPLICATION.pdf
PDF
Become an Agentblazer Champion Challenge Kickoff
PPTX
What to Capture When It Breaks: 16 Artifacts That Reveal Root Causes
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Best Practices for Rolling Out Competency Management Software.pdf
PDF
Multi-factor Authentication (MFA) requirement for Microsoft 365 Admin Center_...
PDF
Understanding Forklifts - TECH EHS Solution
PPTX
Materi-Enum-and-Record-Data-Type (1).pptx
PDF
Build Multi-agent using Agent Development Kit
PPTX
Online Work Permit System for Fast Permit Processing
PPTX
Transform Your Business with a Software ERP System
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
VVF-Customer-Presentation2025-Ver1.9.pptx
How to Confidently Manage Project Budgets
How to Choose the Right IT Partner for Your Business in Malaysia
A REACT POMODORO TIMER WEB APPLICATION.pdf
Become an Agentblazer Champion Challenge Kickoff
What to Capture When It Breaks: 16 Artifacts That Reveal Root Causes
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
IEEE-CS Tech Predictions, SWEBOK and Quantum Software: Towards Q-SWEBOK
How Creative Agencies Leverage Project Management Software.pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
Best Practices for Rolling Out Competency Management Software.pdf
Multi-factor Authentication (MFA) requirement for Microsoft 365 Admin Center_...
Understanding Forklifts - TECH EHS Solution
Materi-Enum-and-Record-Data-Type (1).pptx
Build Multi-agent using Agent Development Kit
Online Work Permit System for Fast Permit Processing
Transform Your Business with a Software ERP System
ISO 45001 Occupational Health and Safety Management System
2025 Textile ERP Trends: SAP, Odoo & Oracle

Java Concurrency - Quiz Questions