Menu
Question Index
...

What will be the output of the following program?

public class Scope {
    public static void main(String[] args) {
        int a = 0;
        int b = 10;
        System.out.println("b = " + c);
        int c = b + a;
        System.out.println("c = " + b);
        a = c + b;
        System.out.println("a = " + a);
    }
}


a = 20
b = 10
c = 10
b = 10
c = 20
a = 10
b = 10
c = 10
a = 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