Menu
Question Index
...

What will be the output of the following program?

import java.io.*;
public class InputStreamDemo {
    public static void main(String args[]) throws IOException {
        byte[] b = {97, 98, 99, 100};
        ByteArrayInputStream bt = new ByteArrayInputStream(b);
        int i = 0;
        while ((i = bt.read()) != -1) {
            char ch = (char) i;
            System.out.print(ch);
        }
        System.out.print(bt.read());
    }
}


979899100
979899100-1
abcd
abcd-1
Compilation Error or Runtime Error

Doubts

Problems

Topic: Java ByteArrayInputStream

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App