What will be printed out while running the following code:

class Synchronized {
    private Synchronized() {}                //1
    private static int order = 0xFace;        //2
    
    public void saySomething(String name) {
        System.out.print(name);
    }
    
    public static void main(String[] args) {
        new Thread() {
            public void run() {
                order++;
                this.yield();                //3
                synchObj.saySomething("I am " + order + " ");
            }
        }.start();                            //4
        new Thread() {
            public void run() {
                ++order;
                this.setPriority(MAX_PRIORITY);
                synchObj.saySomething("I am " + order + " ");
            }
        }.start();                            //4
    }
    private static Synchronized synchObj = new Synchronized();    //5
}

Follow CodeGalaxy

Mobile Beta

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