Menu
Question Index
...

What will be the output of the following program?

import java.io.*;
public class Years {
    public static void main(String args[]) throws IOException {
        byte[] years = {20, 30, 40, 50};
        ByteArrayInputStream leap = new ByteArrayInputStream(years);
        int count = 0;
        while ((count = leap.available()) > 0) {
            char ch = (char) leap.read();
            System.out.print(count + ", ");
        }
    }
}


3, 2, 1, 0
4, 3, 2, 1
Some other output
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