Menu
Question Index
...

At which line will the below program throw an exception, if run with arguments "A B C D D C B A"?

import java.util.Arrays;
public class MainsAndMoreMains {

    public static void main(String[] args) {
        String[] args2 = Arrays.copyOfRange(args, 3, 6); // LINE A
        M.main(args2);
        main(args[0]);
        main(args[7]);
        N.main(Arrays.copyOfRange(args2, 2, 4)); // LINE B
    }

    public static int main(String two) {
        System.out.print(two);
        return two.length();
    }
}
class M {
    public static void main(String[] args) {
        MainsAndMoreMains.main(args[2]); // LINE C
    }
}
class N extends M {
    public static void main(String[] args) {
        System.out.print(args[2]); // LINE D
    }
}


LINE A
LINE B
LINE C
LINE D
The program compiles properly and runs with out any exception

Doubts

Problems

Topic: Unknown

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App