Menu
Question Index
...

What will be the output of the following program?

public class LifeTime {
    public static void main(String[] args) {
        if (true) {
            int x = 10;
            System.out.println("Value of X = " + x);
            x++;
        }
        System.out.println("Value of X = " + x);
    }
}


Value of X = 10
Value of X = 11
Value of X = 10
Value of X = 0
Value of X = 10
Value of X = 10
Compilation Error
Runtime Error

Doubts

Problems

Topic: Lifetime Of Variable In Java

Read this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App