Menu
Topics Index
...
`

Universal Music


If you need explanation Read this topic

If you need Answer Take test on this topic

Universal Music
At lines will we get compilation error?
public class UniversalMusic {
    public static void main(String[] args) {
        /*A*/ int pop = 'P';
        /*B*/ char reggae = 'R';
        {
            /*C*/ System.out.println(pop + " " + reggae + " " + hiphop);
            /*D*/ float hiphop = 31.3f;
            /*E*/ System.out.println(pop + " " + reggae + " " + hiphop);
            /*F*/ double jazz = hiphop;
        }
        /*G*/ System.out.println(pop + " " + reggae + " " + hiphop);
        /*H*/ System.out.println(jazz);
        {
            /*I*/ short hiphop = 850062;
            /*J*/ System.out.println(pop + " " + reggae + " " + hiphop);
        }
        /*K*/ System.out.println(pop + " " + reggae + " " + hiphop);
    }
}

A. A, C, G, H, K
B. C, G, H, K
C. C, G, H, I, K
D. C, D, G, H, K
Topic: Scope Of Variables In Nested/Multiple Blocks

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 c. cline hiphop value nt aasignd,
g line value of hiphop unreachd. h line jaZ value nt reachd,
i line int num is assignd to short varible,
k line hiphop unreachd value or  nt assignd

Posted by Maheshwari Natarajan    2014-05-30 09:06:24


C

Posted by Mouli Kiran    2014-05-30 11:43:34


Answer : C
@C,G,K -> hiphop variable will not be found
@H -> jazz variable will not be found
@I - > the value is going out of short range i.e., loses precision

Posted by Deepak Kumar Yadav    2014-05-30 12:15:57


The answer is C.....you see there is block opening just below 'H' which is an invalid declaration of block....so definetly an error will be shown at the very next line i.e., at ' I '......the only option thats containing ' I' as an error is C...so i can say its 'C'

Posted by Sam Emen    2014-05-30 13:25:32


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

Posted by Merit Campus    2014-06-02 06:57:20


© meritcampus 2019

All Rights Reserved.

Open In App