Menu
Question Index
...

What will be the output of the following program?

public class CoolerMaster
{
    public static void main(String[] args)
    {
        String str = "+Campus+";
        byte[] bytes = str.getBytes();
        for (byte byt : bytes)
        {
            char x = 'X';
            byte b5 = (byt > 65 && byt < 90) ? byt : (byt > 97 && byt < 122) ? byt : (int) x;
            System.out.print(b5 + " ");
        }
    }
}


43 67 97 109 112 117 115 43
88 67 88 109 112 117 115 88
120 67 120 109 112 117 115 120
Compilation Error
Runtime Error

Doubts

Problems

Topic: Java Character Extraction - Java String getBytes() Method

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App