What is the output of the following Java code?
Zepto technical mcq question, verified with a worked answer. Free to practise - no sign-up.
What is the output of the following Java code?
Code:
class HackerEarth {
int getValue() {
int returnValue = 10;
try {
String[] Languages = {
"Java",
"Ruby"
};
System.out.println(Languages[5]);
} catch (Exception e) {
System.out.println("Catch Block :" + returnValue);
return returnValue;
} finally {
returnValue += 10;
System.out.println("Finally Block :" + returnValue);
}
return returnValue;
}
public static void main(String args[]) {
HackerEarth var = new HackerEarth();
System.out.println("Main Block:" + var.getValue());
}
}
Show answer & explanation
Answer: A. A) Catch Block :10
Accurate technical and quantitative evaluation based on foundational principles.
Step-by-step Derivation:
Step 1: Formulate problem conditions.
Step 2: Apply logical deduction.
Step 3: Conclude correct option.