What is the output of following code:

String s = "BIRD";
try {
    String x = "DOG";
    throw new Exception();
} catch (Exception e) {
    s = "CAT";
} finally {
    s = "GOAT";
    x = "FROG";

The x variable, declared in the "try" block is not visible in the "finally" block

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Java quizzes
Sign Up Now
or Subscribe for future quizzes