return in try and finally
QuizMediumJava onlyAsked in: Accenture, Capgemini, Cognizant, Infosys, TCS
What do t() and u() return?
static int t() {
try { return 1; } finally { return 2; }
}
static int u() {
int x = 1;
try { return x; } finally { x = 5; }
}t()returns 2 andu()returns 1t()returns 1 andu()returns 1t()returns 2 andu()returns 5- Neither compiles
This question is part of Pro+
Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.