Menu
Question Index
...

What will be the output of the following program?

public class Kashmir {
    public static void main(String[] args) {
        try {
            KanyaKumari kk = new KanyaKumari();
            kk.run();
            p('A');
            kk.start();
            kk.join();
            p('H');
            kk.run();
            p('M');
            kk.start();
            p('B');
        } catch (Exception ex) {
            p('I');
        }
        p('R');
    }
    private static void p(char c) {
        System.out.print(c);
    }
}
class KanyaKumari extends Thread {
    String s = "KSMI";
    static int i = 0;
    public void run() {
        System.out.print(s.charAt(i++));
    }
}


KASHMMIBR
KASHMMIR
KAHSMIRM
Output can not be determined
Compilation Error or Runtime Error

Doubts

Problems

Topic: What is Multitasking and Multithreading?

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App