Menu
Topics Index
...
`

GATE


If you need explanation Read this topic

If you need Answer Take test on this topic

GATE
What will be the output of the following program?
import java.util.*;
public class TimeUp {
    public static void main(String[] args) {
        StringBuffer exam = new StringBuffer("GATE");
        Formatter time = new Formatter(exam);
        time.close();
        System.out.println(time);
    }
}

A. (EMPTY)
B. GATE
C. Compilation Error
D. Runtime Error
Topic: Java Formatter Methods

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.

Answer is D It throws an Exception that is Run Time Error as exam is an unknown source for Formatter class

Posted by Sai Avinash    2014-08-15 12:45:39


Answer is D as  the Formatter time is closed or resource holded by the formatter object is released, we cant use it after releasing the resource.

Posted by Ashok Kumar Paritala    2014-08-15 12:47:00


Congratulations Ashok Kumar Paritala. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-08-18 05:14:20


© meritcampus 2019

All Rights Reserved.

Open In App