Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
TextInputFormat supplies the byte offset of each line as LongWritable and the line itself as Text.
Question 22 of 60 · Review of the Java code required to handle the Mapper class · Medium
A mapper extends Mapper<LongWritable, Text, Text, IntWritable>. Which statement can be used inside its map() method without causing an output type mismatch?
Not quite. Try another option.
Answer: context.write(new Text(word), new IntWritable(1));
The mapper declaration specifies Text as the output key type and IntWritable as the output value type.
Question 23 of 60 · Review of the Java code required to handle the Reducer class · Medium
Which reducer loop correctly adds all IntWritable values associated with a key?
Not quite. Try another option.
Answer: for (IntWritable value : values) sum += value.get();
get() extracts the integer stored in each IntWritable, allowing the reducer to accumulate the values.
Question 24 of 60 · Review of the Java code required to handle the Reducer class · Medium
A reducer must retain values after iterating over Iterable<IntWritable> values. Which approach is safest because Hadoop may reuse value objects?
Not quite. Try another option.
Answer: Store each result of value.get() in a new integer collection
Hadoop may reuse the same writable object while iterating. Copying the primitive value prevents retained entries from changing unexpectedly.
Question 25 of 60 · Program driver needed to access MapReduce · Medium
A mapper emits <Text, IntWritable>, while the reducer emits <Text, LongWritable>. Which driver configuration correctly declares both output pairs?
waitForCompletion(true) blocks until completion and returns success or failure. Status code 0 conventionally represents success.
Question 27 of 60 · YARN model · Medium
In YARN, which component negotiates containers for one application and coordinates that application's tasks?
Not quite. Try another option.
Answer: ApplicationMaster
Each application has an ApplicationMaster that requests resources from the ResourceManager and coordinates work in allocated containers.
Question 28 of 60 · YARN model · Medium
A YARN worker machine must launch containers and report their status and resource usage. Which component performs these duties?
Not quite. Try another option.
Answer: NodeManager
The NodeManager runs on each worker node, launches containers, monitors them, and reports to the ResourceManager.
Question 29 of 60 · YARN model · Medium
An application requests a YARN container with 4 GB of memory and 2 virtual cores. What does the container primarily represent?
Not quite. Try another option.
Answer: A resource allocation on a cluster node
A YARN container is a bounded allocation of resources, such as memory and virtual cores, on a particular node.
Question 30 of 60 · Java code for word count · Medium
A word-count mapper converts tokens to lowercase before emitting them. What output should the complete job produce for the line Data data DATA?
Not quite. Try another option.
Answer: data 3
Lowercasing converts all three tokens to the same key, so the reducer produces a count of 3 for data.
Question 31 of 60 · Java code for word count · Medium
Why can the word-count reducer class usually also be registered as a combiner?
Not quite. Try another option.
Answer: Integer addition is associative and commutative
Partial word counts can be added in any grouping or order without changing the final count, making local combination safe.
Question 32 of 60 · Java code for word count · Medium
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?
Not quite. Try another option.
Answer: Hadoop serializes the key when it is written
The framework serializes emitted records, so the mapper can reuse writable objects after each context.write() call.
Question 33 of 60 · Java code for sum of even numbers · Medium
A mapper emits only even integers, and the reducer adds them. What result is produced for the input values ?
Not quite. Try another option.
Answer:
The even values are , , and , whose sum is .
Question 34 of 60 · Java code for sum of even numbers · Medium
Which mapper condition correctly recognizes both positive and negative even integers in Java?
Not quite. Try another option.
Answer: number % 2 == 0
An integer is even when its remainder after division by 2 is zero, regardless of whether it is positive, negative, or zero.
Question 35 of 60 · Java code for palindrome · Medium
A palindrome mapper removes non-letter characters and converts the remaining text to lowercase. How should it classify Never odd or even?
Not quite. Try another option.
Answer: Palindrome, because normalization gives neveroddoreven
After removing spaces and ignoring case, the normalized text reads the same forward and backward.
Question 36 of 60 · Java code for palindrome · Medium
A MapReduce palindrome job must preserve a separate result for every input line, including duplicate lines. Which mapper output key is most suitable?
Not quite. Try another option.
Answer: The input line's LongWritable byte offset
Each line's byte offset is unique within the input file, so duplicate text lines remain separate records.
Question 37 of 60 · Java code for factorial · Medium
If factorials are stored in a Java long, what is the largest nonnegative integer for which fits without overflow?
Not quite. Try another option.
Answer:
is smaller than Long.MAX_VALUE, but exceeds the maximum signed 64-bit integer value.
Question 38 of 60 · Java code for factorial · Medium
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?
Not quite. Try another option.
Answer: A single product of
The reducer computes . It does not independently calculate and .
Question 39 of 60 · Java code for Armstrong number · Medium
For a -digit number, which expression should Armstrong-number code compute before comparing the result with the original number?
Not quite. Try another option.
Answer: The sum of each digit raised to the power
A number is Armstrong when it equals the sum of its digits, each raised to the number of digits: .
Question 40 of 60 · Java code for Armstrong number · Medium
A Java mapper checks 9474 using the four-digit Armstrong rule. Which calculation confirms that it is an Armstrong number?
Not quite. Try another option.
Answer:
9474 has four digits, and the sum of the fourth powers of its digits equals the original number.
Question 41 of 60 · Review of the Java code required to handle the Mapper class · Hard
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?
Not quite. Try another option.
Answer: The framework fails when it supplies a LongWritable key and Text value to the mapper
TextInputFormat produces LongWritable byte-offset keys and Text line values. The mapper must therefore use compatible input types, normally Mapper<LongWritable, Text, ...>.
Question 42 of 60 · Review of the Java code required to handle the Mapper class · Hard
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?
Not quite. Try another option.
Answer: This is valid because each map output is serialized when context.write collects it
Hadoop serializes or copies mapper output during collection, so reusing writable instances is a common allocation-saving pattern. Retaining mutable input or value references for later use is a different and unsafe pattern.
Question 43 of 60 · Review of the Java code required to handle the Reducer class · Hard
Why can the following reducer logic produce an incorrect list even though the loop visits all values? for (IntWritable v : values) saved.add(v);
Not quite. Try another option.
Answer: The framework may reuse the same IntWritable instance while advancing the iterator
The values iterator may reuse mutable writable objects. Save primitive copies such as v.get() or construct new IntWritable instances instead of retaining the iterator's references.
Question 44 of 60 · Review of the Java code required to handle the Reducer class · Hard
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?
Not quite. Try another option.
Answer: One call per customer, with that customer's values encountered in timestamp sort order
This is the secondary-sort pattern. Grouping defines one reduce group per customer, while the full sort comparator arranges records within that group by timestamp.
Question 45 of 60 · Program driver needed to access MapReduce · Hard
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?
Not quite. Try another option.
Answer: setMapOutputKeyClass(Text.class) and setMapOutputValueClass(IntWritable.class)
When map-output classes are not set explicitly, Hadoop defaults them to the final output classes. Different intermediate and final value types therefore require separate map-output configuration.
Question 46 of 60 · Program driver needed to access MapReduce · Hard
A driver configures job.setNumReduceTasks(0) for a map-only job. Which type constraint now applies to records written by the mapper?
Not quite. Try another option.
Answer: Mapper output types must match the job's final output key and value classes
With zero reducers, mapper output is final output. There is no shuffle or reducer to transform intermediate types into different result types.
Question 47 of 60 · YARN model · Hard
Which YARN component is primarily responsible for negotiating containers for one submitted MapReduce job and coordinating its tasks?
Not quite. Try another option.
Answer: The job's ApplicationMaster
The per-application ApplicationMaster requests containers from the ResourceManager and coordinates tasks running in those containers. NodeManagers launch and monitor containers on individual nodes.
Question 48 of 60 · YARN model · Hard
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?
Not quite. Try another option.
Answer: Relax the request from node-local to rack-local and eventually off-rack placement
Container requests can express node and rack preferences, then relax locality after waiting. This balances data locality against the cost of leaving cluster resources idle.
Question 49 of 60 · YARN model · Hard
A NodeManager stops sending heartbeats after launching several task containers. Which response best matches the YARN execution model?
Not quite. Try another option.
Answer: The ResourceManager marks the node unhealthy or lost, and the application can reschedule affected work
Heartbeats provide node and container status. Lost containers are not migrated with their process memory; the application framework typically reruns the affected tasks in new containers.
Question 50 of 60 · Java code for word count · Hard
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?
Not quite. Try another option.
Answer: The map must be task-local, and its memory usage must be bounded for high-cardinality input
In-mapper combining is correct when each task emits its local totals, but retaining every distinct word can exhaust heap space. Periodic flushing can bound memory while preserving additive counts.
Question 51 of 60 · Java code for word count · Hard
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?
Not quite. Try another option.
Answer: Integer count addition is associative and commutative
Partial sums can be regrouped and recombined without changing the final count. Correctness cannot depend on the combiner running or seeing all values for a key.
Question 52 of 60 · Java code for word count · Hard
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?
Not quite. Try another option.
Answer: token.toLowerCase(Locale.ROOT)
Locale.ROOT provides locale-neutral normalization across worker machines. Using each worker's default locale can produce different keys for some characters.
Question 53 of 60 · Java code for sum of even numbers · Hard
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?
Not quite. Try another option.
Answer: Parse with Long.parseLong, test n % 2 == 0, and aggregate with LongWritable
Using long throughout avoids premature 32-bit overflow. The test n % 2 == 0 also works for both positive and negative even numbers.
Question 54 of 60 · Java code for sum of even numbers · Hard
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?
Not quite. Try another option.
Answer: All records have the same logical key and are therefore routed to one reduce group
NullWritable has one logical key value, so all partial sums form one group. This supports a global result but creates a single-key aggregation bottleneck.
Question 55 of 60 · Java code for palindrome · Hard
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?
Not quite. Try another option.
Answer: Remove non-alphanumeric code points and apply locale-neutral case normalization
Ignoring punctuation, spaces, and case requires a canonical representation before reversal. Sorting is unsuitable because it discards character order.
Question 56 of 60 · Java code for palindrome · Hard
A mapper emits <word, 1> only when word is a palindrome, and a reducer sums values by word. What does the final output represent?
Not quite. Try another option.
Answer: The occurrence count of each distinct palindromic word
The shuffle groups records by the emitted word, so each reducer call counts occurrences of one distinct palindrome. A constant key would be needed for one global count.
Question 57 of 60 · Java code for factorial · Hard
A Java mapper calculates factorials using a signed long and must detect overflow before multiplication. For positive i, which check should precede result *= i?
Not quite. Try another option.
Answer: result > Long.MAX_VALUE / i
Division-based checking detects overflow before it occurs. Evaluating result * i first is unreliable because the multiplication may already have wrapped around.
Question 58 of 60 · Java code for factorial · Hard
A factorial job replaces long with BigInteger and needs to emit exact results through Hadoop. Which design is valid?
Not quite. Try another option.
Answer: Serialize the result as Text or implement a dedicated Writable for BigInteger
BigInteger is not a Hadoop Writable, and LongWritable cannot expand beyond 64 bits. Decimal Text or a custom writable preserves the exact value.
Question 59 of 60 · Java code for Armstrong number · Hard
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?
Not quite. Try another option.
Answer: The number 0 must be treated as having one digit
A loop that counts digits only while temp > 0 reports zero digits for 0. Decimal zero has one digit and satisfies .
Question 60 of 60 · Java code for Armstrong number · Hard
Why is (long) Math.pow(digit, digitCount) potentially unsafe in an exact Armstrong-number test for large inputs?
Not quite. Try another option.
Answer: Math.pow uses floating-point arithmetic and may round before the cast
Math.pow returns a double, which cannot represent every large integer exactly. Exact integer exponentiation with checked long arithmetic or BigInteger.pow avoids rounding errors.
That's unit 3
Answer a few questions and your score shows up here.
Nearly through. Did unit 3 of INT312 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 3 of INT312 save you a night before the exam?
Then you can help keep it free for the next batch. 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.