Menu
Question Index
...

What will be the output of the following program?

public class Cricket {
    static boolean ball;
    public static void main(String[] args) {
        short bat = 42;
        if (bat < 50 & !ball)
            bat++;
        if (bat > 50)
            ;
        else if (bat > 40) {
            bat += 7;
            bat++;
        }
        else
            --bat;
        System.out.println(bat);
    }
}


41
42
50
51
Compilation Error or Runtime Error

Doubts

Problems

Topic: Static Keyword In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App