Menu
Topics Index
...
`

Print Reverse


If you need explanation Read this topic

If you need Answer Take test on this topic

Print Reverse
What will be the output of the following program?
public class PrintReverse {

    public static void main(String[] args) {
        int i = 25, j = 2;
        while (i > 9 || j < 20) {
            i -= 3;
            j += 2;
            System.out.print(i + j + "^");
        }
    }
}

A. 224^196^168^1310^1012^714^416^118^-220^
B. 224^196^168^1310^1012^714^
C. 224^196^168^1310^1012^714^416^118^-220^-522^
D. Some other output or Compilation Error
Topic: while Loop 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,  there is no compilation errors and it returns some other output(26^25^24^23^22^21^20^19^18^).

Posted by Damu Surya    2014-07-16 13:15:39


ans d bcz
we get some other output
first time while()is true n values are i=22,j=4 but in print stmt i+j=26
then next time i=19 j=6 and so on
so we get output as 26^25^24^23^22^21^19^18

Posted by Pooja Singh    2014-07-16 13:16:08


ans is d...the output will be 26^25^..............^18

Posted by Vijay Kumar    2014-07-16 13:27:29


A

Posted by Rishav Seksaria    2014-07-16 15:33:21


Congratulations Damodar U Ukkala. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-07-17 09:12:46


© meritcampus 2019

All Rights Reserved.

Open In App