Unit 3: Map Reduce and YARN - Practice Quiz
1 Which Hadoop class is commonly extended to create a custom Mapper?
2 Which method contains the main processing logic of a Hadoop Mapper?
3
Which statement is used to emit a key-value pair from the map() method?
4 Which Hadoop class is commonly extended to create a custom Reducer?
5
What does the values parameter of a Reducer's reduce() method normally contain?
6 Which Java loop is commonly used to process all values received by a Reducer?
for loop
for loop
while loop
do-while loop
7 Which method usually serves as the entry point of a Java MapReduce driver program?
8 Which driver method sets the Mapper class for a Hadoop job?
9
What does job.waitForCompletion(true) do in a MapReduce driver?
10 What does YARN stand for in Hadoop?
11 Which YARN component manages resources across the entire cluster?
12 Which YARN component manages containers on an individual worker machine?
13 In a standard Word Count Mapper, what value is usually emitted for each word occurrence?
1
0
14 What operation does a Word Count Reducer perform on the values for each word?
15
Which Java condition correctly checks whether an integer n is even?
n % 2 == 1
n + 2 == 0
n % 2 == 0
n / 2 == 0
16 What is the sum of the even numbers in the list ?
17 Which comparison can confirm that an integer is a palindrome after its digits have been reversed?
original > reversed
original == reversed
original != reversed
original < reversed
18 Which number is a palindrome?
19 What initial value should a factorial accumulator normally have in Java?
0
2
-1
1
20 What is the value of ?
21
A mapper processes a text file using Hadoop's default TextInputFormat. Which declaration correctly represents the mapper's input types?
Mapper<LongWritable, Text, Text, IntWritable>
Mapper<IntWritable, Text, LongWritable, Text>
Mapper<NullWritable, Text, Text, LongWritable>
Mapper<Text, LongWritable, Text, IntWritable>
22
A mapper extends Mapper<LongWritable, Text, Text, IntWritable>. Which statement can be used inside its map() method without causing an output type mismatch?
context.write(new Text(word), new IntWritable(1));
context.write(new LongWritable(1), new Text(word));
context.write(new Text(word), new LongWritable(1));
context.write(new IntWritable(1), new Text(word));
23
Which reducer loop correctly adds all IntWritable values associated with a key?
for (IntWritable value : values) sum += value.hashCode();
for (IntWritable value : values) sum = value.get();
for (IntWritable value : values) sum += value.get();
for (IntWritable value : values) sum += values.size();
24
A reducer must retain values after iterating over Iterable<IntWritable> values. Which approach is safest because Hadoop may reuse value objects?
values iterator and traverse it after reduction
value.get() in a new integer collection
value reference directly in an object collection
25
A mapper emits <Text, IntWritable>, while the reducer emits <Text, LongWritable>. Which driver configuration correctly declares both output pairs?
setMapOutputKeyClass(IntWritable.class), setMapOutputValueClass(Text.class), setOutputKeyClass(LongWritable.class), setOutputValueClass(Text.class)
setMapOutputKeyClass(Text.class), setMapOutputValueClass(LongWritable.class), setOutputKeyClass(Text.class), setOutputValueClass(IntWritable.class)
setMapOutputKeyClass(Text.class), setMapOutputValueClass(IntWritable.class), setOutputKeyClass(Text.class), setOutputValueClass(LongWritable.class)
setMapOutputKeyClass(LongWritable.class), setMapOutputValueClass(Text.class), setOutputKeyClass(IntWritable.class), setOutputValueClass(Text.class)
26 Which driver statement waits for job completion and returns a conventional process status code?
System.exit(job.waitForCompletion(true) ? 0 : 1);
System.exit(job.submit() ? 0 : 1);
System.exit(job.isComplete() ? 1 : 0);
System.exit(job.waitForCompletion(false) ? 1 : 0);
27 In YARN, which component negotiates containers for one application and coordinates that application's tasks?
28 A YARN worker machine must launch containers and report their status and resource usage. Which component performs these duties?
29 An application requests a YARN container with 4 GB of memory and 2 virtual cores. What does the container primarily represent?
30
A word-count mapper converts tokens to lowercase before emitting them. What output should the complete job produce for the line Data data DATA?
DATA 3
Data 1, data 2
Data 1, data 1, DATA 1
data 3
31 Why can the word-count reducer class usually also be registered as a combiner?
32
A mapper declares one reusable Text word = new Text(); field. For each token, it calls word.set(token) followed immediately by context.write(word, one). Why is this normally valid?
Text objects globally immutable
33 A mapper emits only even integers, and the reducer adds them. What result is produced for the input values ?
34 Which mapper condition correctly recognizes both positive and negative even integers in Java?
number % 2 == 0
number / 2 == 0
number > 0 && number % 2 == 0
number % 2 == 1
35
A palindrome mapper removes non-letter characters and converts the remaining text to lowercase. How should it classify Never odd or even?
neveroddoreven
36 A MapReduce palindrome job must preserve a separate result for every input line, including duplicate lines. Which mapper output key is most suitable?
NullWritable key for every line
Text key
LongWritable byte offset
BooleanWritable palindrome key
37
If factorials are stored in a Java long, what is the largest nonnegative integer for which fits without overflow?
38
A mapper sends input numbers 3 and 4 under the same NullWritable key. The reducer initializes product = 1 and multiplies every received number once. What does this job output?
39 For a -digit number, which expression should Armstrong-number code compute before comparing the result with the original number?
40
A Java mapper checks 9474 using the four-digit Armstrong rule. Which calculation confirms that it is an Armstrong number?
41
A job uses TextInputFormat and declares Mapper<Text, LongWritable, Text, IntWritable>. The mapper's map method has the same declared parameter types. What is the most likely result when the job processes input?
LongWritable key and Text value to the mapper
Text before invoking the mapper
42
A mapper creates one Text object as a field, changes its contents for every token, and calls context.write(reusedText, ONE) after each change. Under the normal Hadoop mapper output path, which statement is correct?
context.write collects it
43
Why can the following reducer logic produce an incorrect list even though the loop visits all values? for (IntWritable v : values) saved.add(v);
IntWritable instance while advancing the iterator
WritableComparator
44
A composite mapper key is (customerId, timestamp). The sort comparator orders both fields, while the grouping comparator compares only customerId. What behavior does the reducer receive?
45
A mapper emits <Text, IntWritable>, but the reducer emits <Text, LongWritable>. The driver sets only setOutputKeyClass(Text.class) and setOutputValueClass(LongWritable.class). What configuration is missing?
setInputFormatClass(TextInputFormat.class) and setNumReduceTasks(1)
setOutputFormatClass(TextOutputFormat.class) and setJarByClass(LongWritable.class)
setPartitionerClass(HashPartitioner.class) and setCombinerClass(Reducer.class)
setMapOutputKeyClass(Text.class) and setMapOutputValueClass(IntWritable.class)
46
A driver configures job.setNumReduceTasks(0) for a map-only job. Which type constraint now applies to records written by the mapper?
NullWritable, but mapper values may use any writable type
47 Which YARN component is primarily responsible for negotiating containers for one submitted MapReduce job and coordinating its tasks?
48 An ApplicationMaster first requests a map container on the node holding an input block, but that node lacks resources. How can YARN improve progress while still considering locality?
49 A NodeManager stops sending heartbeats after launching several task containers. Which response best matches the YARN execution model?
50
A word-count mapper performs in-mapper combining by storing counts in a HashMap<String, Integer> and emitting them in cleanup. What is the main correctness and scalability requirement?
51 A word-count job uses the ordinary sum reducer as its combiner. Which assumption makes this valid even though Hadoop may invoke the combiner zero, one, or multiple times?
52
Two mapper tasks tokenize "Data" and "data". The reducer must produce one case-insensitive count independent of the workers' default locales. Which mapper normalization is most appropriate?
token.equalsIgnoreCase(previousToken)
token.toUpperCase(Locale.getDefault())
token.toLowerCase()
token.toLowerCase(Locale.ROOT)
53 A job must exactly sum all even signed 64-bit input values whenever the mathematical result fits in a signed 64-bit integer. Which implementation is appropriate?
Double.parseDouble, test the low binary bit after conversion, and round the reducer's floating-point total back to a signed integer
Integer.parseInt, test n % 2 == 0, and cast the final sum to long
Long.parseLong, test n % 2 == 0, and aggregate with LongWritable
Long.parseLong, test n % 2 == 1, and aggregate with LongWritable
54
Each mapper emits <NullWritable, partialEvenSum>, and the reducer adds all partial sums. Why is NullWritable a suitable key only when a single global sum is intended?
55
A palindrome job should treat "A man, a plan, a canal: Panama" as a palindrome. Which transformation must occur before comparing the text with its reverse?
56
A mapper emits <word, 1> only when word is a palindrome, and a reducer sums values by word. What does the final output represent?
57
A Java mapper calculates factorials using a signed long and must detect overflow before multiplication. For positive i, which check should precede result *= i?
result > Long.MAX_VALUE % i
result + i > Long.MAX_VALUE
result > Long.MAX_VALUE / i
result * i > Long.MAX_VALUE
58
A factorial job replaces long with BigInteger and needs to emit exact results through Hadoop. Which design is valid?
LongWritable because Hadoop automatically expands its capacity
Text or implement a dedicated Writable for BigInteger
DoubleWritable because every integer has an exact floating-point representation
BigInteger directly because every Serializable Java object is automatically a Hadoop writable
59 For a nonnegative decimal integer with digits, an Armstrong-number mapper must test whether . Which edge case requires explicit attention when digit counting uses repeated division by 10?
0 must be treated as having one digit
0 must be treated as having an extra digit
0
60
Why is (long) Math.pow(digit, digitCount) potentially unsafe in an exact Armstrong-number test for large inputs?
Math.pow calculates modular exponentiation and discards higher decimal digits
Math.pow returns negative values whenever the exponent exceeds nine
Math.pow always interprets both arguments as hexadecimal numbers
Math.pow uses floating-point arithmetic and may round before the cast
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill. The rest comes out of a student's own pocket: the domain, the storage, and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason. to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it. What it pays for →