Menu
Question Index
...

What will be the output of the following program?

public class SamsungDuos
{
    public static void main(String[] args)
    {
        char first;
        int second;
        for (first = 98, second = 'b'; first < 106 || second <= 106; second++, first++)
        {
            int temp = 0, temp1 = 0;
            temp1 = second - 30;
            temp += (first - 30);
            String str = "106";
            System.out.print(temp1 + "--" + (char) temp + (!str.equals(Integer.toString(second)) ? ", " : " "));
        }
    }
}


68--D, 69--E, 70--F, 71--G, 72--H, 73--I, 74--J, 75--K, 76--L
68--D, 69--E, 70--F, 71--G, 72--H, 73--I, 74--J, 75--K,
68--B, 69--C, 70--D, 71--E, 72--F, 73--G, 74--H, 75--I, 76--J
Compilation Error because type mismatch
Compilation Error or Runtime Error for some other reason

Doubts

Problems

Topic: Java equals method vs == Operator

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App