Menu
Question Index
...

What will be the output of the following program?

public class ByteExample
{
    public static void main(String[] args)
    {
        String str = "BCDEFG";
        byte[] bytes = str.getBytes();
        for (byte byt : bytes)
        {
            System.out.print((char) byt + " ");
            byt--;
        }
    }
}


B C D E F G
A B C D E F
B B C D E F
B B B B B B
Program goes into infinite loop

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