Menu
Topics Index
...
`

Orange Mango Banana


If you need explanation Read this topic

If you need Answer Take test on this topic

Orange Mango Banana
What will be the output of the following program?
public class OrangeMangoBanana {
    final static int orange, mango;
    static int banana;
    static {
        mango = orange + 3;
        banana = mango * 2;
    }
    public static void main(String[] args) {
        System.out.print(orange + " " + mango + " " + banana + " ");
        banana = mango + orange + banana;
        System.out.print(banana);
    }
    static {
        orange = 25;
    }
}

A. 25 28 56 109
B. 0 3 6 9
C. Some other output
D. Compilation Error
Topic: Static Keyword In Java

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: D Compilation  we must initialize final variable while declaring variable.

Posted by Indrasena Reddy    2014-05-27 07:15:37


ans : d as a public CLASS is required in main file

Posted by Manasa Jyothi Sree    2014-05-27 09:47:42


No winner for this dose. Correct option is 'D"  :(

Posted by Merit Campus    2014-05-28 14:58:38


I have given right answer for 392A.please give reason why it is worng for improving my knowledge. Merit Campus

Posted by Indrasena Reddy    2014-05-29 06:04:59


Indrasena Reddy although your answer is correct, you did not get the recharge because you already won 391B.

Posted by Merit Campus    2014-05-29 06:30:18


As you know for the simple and medium doses, we can only win once per week. :-)

Posted by Merit Campus    2014-05-29 06:30:46


Hope this clarifies. All rules and more info at http://java.meritcampus.com/dailydose

Posted by Merit Campus    2014-05-29 06:31:19


Thanks for pariticipating.

Posted by Merit Campus    2014-05-29 06:31:59


Thanx for giving response.

Posted by Indrasena Reddy    2014-05-29 07:02:46


© meritcampus 2019

All Rights Reserved.

Open In App