Bird
Raised Fist0

What will happen if you try to get a non-existent JMX attribute like this?

medium📝 Predict Output Q5 of Q15
Kafka - Monitoring and Operations
What will happen if you try to get a non-existent JMX attribute like this? ObjectName name = new ObjectName("kafka.server:type=BrokerTopicMetrics,name=MessagesInPerSec"); String value = (String) mbeanServer.getAttribute(name, "NonExistentAttr"); System.out.println(value);
APrints empty string
BPrints null
CPrints "NonExistentAttr"
DThrows AttributeNotFoundException
Step-by-Step Solution
Solution:
  1. Step 1: Understand JMX behavior on missing attribute

    Requesting a non-existent attribute throws AttributeNotFoundException.
  2. Step 2: Casting does not prevent exception

    Since attribute is missing, exception occurs before casting or printing.
  3. Final Answer:

    Throws AttributeNotFoundException -> Option D
  4. Quick Check:

    Missing attribute = Exception thrown [OK]
Quick Trick: Missing JMX attribute causes exception, not null [OK]
Common Mistakes:
MISTAKES
  • Expecting null instead of exception
  • Assuming empty string output
  • Thinking attribute name prints

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes