Bird
Raised Fist0

Given the following Java snippet to get a Kafka JMX metric attribute, what will be the output if the metric value is 150?

medium📝 Predict Output Q13 of Q15
Kafka - Monitoring and Operations
Given the following Java snippet to get a Kafka JMX metric attribute, what will be the output if the metric value is 150?
ObjectName name = new ObjectName("kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec");
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
Integer value = (Integer) mbs.getAttribute(name, "Count");
System.out.println(value);
AMBeanServerException
Bnull
CCount
D150
Step-by-Step Solution
Solution:
  1. Step 1: Understand the code's purpose

    The code queries the JMX MBeanServer for the 'Count' attribute of the specified metric.
  2. Step 2: Interpret the output

    If the metric value is 150, the printed output will be the integer 150.
  3. Final Answer:

    150 -> Option D
  4. Quick Check:

    Metric value printed = 150 [OK]
Quick Trick: JMX attribute value prints directly if metric exists [OK]
Common Mistakes:
MISTAKES
  • Expecting attribute name instead of value
  • Assuming null if metric exists
  • Confusing exceptions with normal output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes