Menu
Topics Index
...
`

USingSkip


If you need explanation Read this topic

If you need Answer Take test on this topic

USingSkip
What will be the output of the following program?
import java.io.*;
public class USingSkip {
    public static void main(String args[]) throws IOException {
        byte[] b = {25, 35, 45, 55};
        ByteArrayInputStream array = new ByteArrayInputStream(b);
        int m = 0;
        while ((m = array.read()) != -1) {
            array.skip(2);
            System.out.println(m);
        }
    }
}

A. 25
45
B. 25
35
C. 25
55
D. Some other output
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 C.. skip functions skips 2 elemnts in the array..

Posted by Nanda Kishore    2014-04-29 03:40:37


ans : c
bcz skip() skip two elements
read() returns -1 when end of the array reached

Posted by Ananda Kumar    2014-04-29 03:40:40


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

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


© meritcampus 2019

All Rights Reserved.

Open In App