Qtr No. 213, New Town Yehlanka
Indore 454775, India
Given:
void getValue(Object value) {
if (!(value instanceof Integer input))
System.out.print("Integer!");
else if (!(value instanceof String input)) { // Line 1
throw new RuntimeException();
}
System.out.print("String!");
}What is the output produced on calling getValue("integer")? (Assume the code is present inside in a valid class.)
Integer!
Integer! followed by an exception.
Pattern matching with an if statement is implemented using the instanceof operator.
Integer! String!
To get all Infosys Certified Java SE 21 Developer Exam questions Join Telegram Group https://rebrand.ly/lex-telegram-236dee