Menu
Question Index
...

What will be the output of the following program?

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


Book name java
Pages 300
Price 275.50D
Book name java
Pages 300
Price 275.5
Book name java
Pages 0
Price 275.5
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