Menu
Question Index
...

What will be the output of following program?

public class Addition {
    public static String bean = "";
    public static String fast(int i) {
        try {
            if (i == 1) {
                throw new Exception();
            }
            bean += "1";
        } catch (Exception e) {
            bean += "2";
        } finally {
            bean += "3";
        }
        bean += "4";
        return bean;
    }
    public static void main(String args[]) {
        fast(0);
        String fine = fast(1);
        System.out.println(fine);
    }
}


1342
134234
132432
Someother output
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java Throw Keyword - Java Throws Keyword

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App