Menu
Question Index
...

What will be the output of the following program?

public class Book {
    public static void main(String[] args) {
        String book = "java";
        System.out.println("Book name " + book);
        {
            int pages = 300;
            System.out.println("Pages " + pages);
            double price = 275.50D;
        }
        price = 275;
        System.out.println("Price " + price);
    }
}


Book name java
Pages 300
Price 275.0
Book name java
Pages 300
Price 275.5
Book name java
Pages 300
Price 275.50D
Compilation Error
Runtime Error

Doubts

Problems

Topic: Scope Of Variables In Nested/Multiple Blocks

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App