Menu
Question Index
...

What will be the output of the following program?

public class ScopeOfVariables {
    public static void main(String[] args) {
        int x = 10;
        System.out.print(x + ", " + y);
        int y = 20;
        x = 15;
        System.out.print(" - " + x + ", " + y);
    }
}


10, 20 - 15, 20
10, 0 - 15, 20
Compilation Error
Runtime Error

Doubts

Problems

Topic: Scope Of Variables In Same Block

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App