Menu
Question Index
...

What will be the output of the following program?

import java.nio.*;

public class Buffers {
    public static void main(String[] args) {
        FloatBuffer floatBuf = FloatBuffer.allocate(10);
        floatBuf.put(0);
        floatBuf.put(1);
        floatBuf.put(0);
        floatBuf.put(0);
        System.out.print(floatBuf.position() + ", ");
        floatBuf.put(5);
        floatBuf.put(56);
        System.out.print(floatBuf.capacity() + ", ");
        floatBuf.put(66.6);
        System.out.print(floatBuf.limit() + ", ");
        System.out.println(floatBuf.remaining());
        floatBuf.put(56);
    }
}


3, 9, 10, 3
4, 10, 10, 3
Some other output
Output can not be determined
Compilation Error or Runtime Error

Doubts

Problems

Topic: Other Advanced Topics In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App