Menu
Topics Index
...
`

Inner Class


If you need explanation Read this topic

If you need Answer Take test on this topic

Inner Class
What will be the output of the following program?
public class PrintZValue {
    double z = 'c';
    public static void main(String[] args) {
        PrintZValue pv = new PrintZValue();
        pv.new Print().value();
    }
    class Print {
        int x = 15;
        void value() {
            System.out.println("Output " + x + z);
        }
    }
}

A. Output 114
B. Output 114.0
C. Some other output
D. Compilation Error or Runtime Error
Topic: Advanced Java Programming Concepts

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Ans is : C, o/p is : Output 1599.0

Posted by Mallikarjuna Rao    2014-02-04 04:24:08


As is B when we add double value with int value o/p result will be double value and when we use + with string output will be concatinated with 114.0

Posted by Ram Reddy Bitla    2014-02-04 07:06:09


ANS-c

Posted by Kick Bhasha    2014-02-04 10:48:04


Congratulations Mallikarjuna Rao. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-02-05 04:17:51


© meritcampus 2019

All Rights Reserved.

Open In App