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

PDF
spring-boot-fr.pdf
PDF
Grokking Techtalk #46: Lessons from years hacking and defending Vietnamese banks
PDF
Overview of secret management solutions and architecture
PPTX
Scrum Guide
PPTX
An intro to Docker, Terraform, and Amazon ECS
PDF
Netflix: A State of Xen - Chaos Monkey & Cassandra
PDF
Docker Compose 徹底解説
PDF
オブジェクト指向エクササイズのススメ
spring-boot-fr.pdf
Grokking Techtalk #46: Lessons from years hacking and defending Vietnamese banks
Overview of secret management solutions and architecture
Scrum Guide
An intro to Docker, Terraform, and Amazon ECS
Netflix: A State of Xen - Chaos Monkey & Cassandra
Docker Compose 徹底解説
オブジェクト指向エクササイズのススメ

What's hot (20)

PDF
Cloud adoption fails - 5 ways deployments go wrong and 5 solutions
PPTX
Scrum - Requirements and User Stories
PDF
Application Performance Monitoring with OpenTelemetry
PDF
なかったらINSERTしたいし、あるならロック取りたいやん?
PDF
User story and splitting workshop
PPT
Selenium
PDF
Quarkus - a next-generation Kubernetes Native Java framework
PDF
Formation Spring Avancé gratuite par Ippon 2014
PDF
FlutterでGraphQLを扱う
PDF
이벤트 기반 분산 시스템을 향한 여정
PPTX
Gestion de projets agiles avec scrum actiskills
PDF
Dockerからcontainerdへの移行
PPTX
Why you should switch to Cypress for modern web testing?
PPTX
Cypress Automation
PDF
En route vers Java 21 - Javaday Paris 2023
PPTX
インフラエンジニアのお仕事 ~ daemontools から systemdに乗り換えた話 ~
PPTX
Mobile UI Testing using Appium and Docker
PDF
Clean architectures with fast api pycones
PPTX
PHP と SAPI と ZendEngine3 と
PPTX
Cloud adoption fails - 5 ways deployments go wrong and 5 solutions
Scrum - Requirements and User Stories
Application Performance Monitoring with OpenTelemetry
なかったらINSERTしたいし、あるならロック取りたいやん?
User story and splitting workshop
Selenium
Quarkus - a next-generation Kubernetes Native Java framework
Formation Spring Avancé gratuite par Ippon 2014
FlutterでGraphQLを扱う
이벤트 기반 분산 시스템을 향한 여정
Gestion de projets agiles avec scrum actiskills
Dockerからcontainerdへの移行
Why you should switch to Cypress for modern web testing?
Cypress Automation
En route vers Java 21 - Javaday Paris 2023
インフラエンジニアのお仕事 ~ daemontools から systemdに乗り換えた話 ~
Mobile UI Testing using Appium and Docker
Clean architectures with fast api pycones
PHP と SAPI と ZendEngine3 と
Ad

Similar to Java Concurrency - Quiz Questions (20)

PDF
The answer is b
PDF
Learning In Nonstationary Environments: Perspectives And Applications. Part1:...
DOCX
Ompp3 om (operations management) practical project problems are
PDF
Disaster Recovery Planning Powerpoint Presentation Slides
PDF
Disaster Recovery Planning PowerPoint Presentation Slides
PPTX
Building Continuous Learning Systems
PDF
Agile basic introduction
PPTX
Project-Planning-Report for Masters of Education
DOC
Advanced Maintenance And Reliability (Best Practices in Maintenance and Relia...
DOC
Advanced Maintenance And Reliability (Best Maintenance and Reliability Practi...
PDF
ML-advice machine learning forn applying
PDF
Barga Data Science lecture 9
PPTX
How to Predict Your Software Project's Probability of Success
PDF
Twelve Heuristics for Solving Tough Problems Faster and Better
PDF
Narrated Version Dallas MPUG
PDF
ProbStat-Mod01.pdf
PDF
Metric Free Test Management by Joseph Ours
PPT
Agile development
DOCX
AC 554 Entire Course New
PDF
K to 12 computer hardware servicing
The answer is b
Learning In Nonstationary Environments: Perspectives And Applications. Part1:...
Ompp3 om (operations management) practical project problems are
Disaster Recovery Planning Powerpoint Presentation Slides
Disaster Recovery Planning PowerPoint Presentation Slides
Building Continuous Learning Systems
Agile basic introduction
Project-Planning-Report for Masters of Education
Advanced Maintenance And Reliability (Best Practices in Maintenance and Relia...
Advanced Maintenance And Reliability (Best Maintenance and Reliability Practi...
ML-advice machine learning forn applying
Barga Data Science lecture 9
How to Predict Your Software Project's Probability of Success
Twelve Heuristics for Solving Tough Problems Faster and Better
Narrated Version Dallas MPUG
ProbStat-Mod01.pdf
Metric Free Test Management by Joseph Ours
Agile development
AC 554 Entire Course New
K to 12 computer hardware servicing
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
medical staffing services at VALiNTRY
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Introduction to Artificial Intelligence
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
System and Network Administraation Chapter 3
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPT
Introduction Database Management System for Course Database
PPTX
assetexplorer- product-overview - presentation
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Digital Strategies for Manufacturing Companies
medical staffing services at VALiNTRY
Design an Analysis of Algorithms II-SECS-1021-03
Introduction to Artificial Intelligence
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Design an Analysis of Algorithms I-SECS-1021-03
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
wealthsignaloriginal-com-DS-text-... (1).pdf
Operating system designcfffgfgggggggvggggggggg
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Wondershare Filmora 15 Crack With Activation Key [2025
Softaken Excel to vCard Converter Software.pdf
System and Network Administraation Chapter 3
Upgrade and Innovation Strategies for SAP ERP Customers
PTS Company Brochure 2025 (1).pdf.......
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Introduction Database Management System for Course Database
assetexplorer- product-overview - presentation
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Digital Strategies for Manufacturing Companies

Java Concurrency - Quiz Questions