Menu
Question Index
...

What will be the output of the following program?

public class Bowler {
    int runs = 81;
    public static void main(String[] args) {
        new Bowler().go();
    }
    int balls = 75;
    void go() {
        incr(++runs);
        dec(--balls);
        System.out.print(runs + ",");
        System.out.print(balls + ",");
    }
    void incr(int runs) {
        runs += 10;
    }
    void dec(int balls) {
        balls -= 20;
        System.out.print(balls + ",");
    }
}


82,54,74,
54,74,82
82,55,74
54,82,74,
Compilation Error or Runtime Error.

Doubts

Problems

Topic: Java Multiple Methods In One Class

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App