Menu
Topics Index
...
`

PlayingCards


If you need explanation Read this topic

If you need Answer Take test on this topic

PlayingCards
What will be the output of the following program?
import java.io.*;
public class PlayingCards {
    public static void main(String args[]) throws IOException {
        byte[] king = {72, 73, 74, 75};
        ByteArrayInputStream joker = new ByteArrayInputStream(king);
        byte[] b = new byte[4];
        int num = joker.read(b, 1, 2);
        System.out.print(num + ", " + joker.read());
    }
}

A. 1, 72
B. 2, 74
C. 1, H
D. 2, J
E. Compilation Error or Runtime Error
Topic: Java ByteArrayInputStream

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

Ans is b...read method wl give 2 and joker.read() meas it wl give 74

Posted by Cherry Teegala    2014-03-27 03:53:08


read will return the next byte of data.read(b,1,2) will return 2 bytes as b is of 2 bytes and joker.read will return the next value i.e.,74

Posted by Chintu Raparthi    2014-03-27 11:52:06


Congratulations Chota Viru. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-03-28 04:30:10


© meritcampus 2019

All Rights Reserved.

Open In App