Menu
Topics Index
...
`

You like


If you need explanation Read this topic

If you need Answer Take test on this topic

You like
What will be the output of the following program?
import java.util.*;
public class ILike {
    public static void main(String[] args) {
        String like;
        Formatter convert = new Formatter();
        convert.format("pen");
        convert.format("~pencil");
        like = convert.toString();
        System.out.println(like);
    }
}

A. ~pencil
B. pen~pencil
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.

b.Thejava.util.Formatter.format(String format,Object... args)method writes a formatted string to this object's destination using the specified format string and arguments. The locale used is the one defined during the construction of this formatter.

format-- A format string as described in Format string syntax.
hence pen pencik r inputed n reslt is penpencil

Posted by Shamee Shamee    2014-08-20 04:21:17


ans is  b the format function returns string "pen" and "~pencil" to the object which inturn gets appended

Posted by Akash Kolariya    2014-08-20 04:22:17


ans is b because the formatter return sting pen and ~pencil to the object

Posted by Sudhanshu Tiwari    2014-08-20 05:04:24


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

Posted by Merit Campus    2014-08-21 05:15:58


© meritcampus 2019

All Rights Reserved.

Open In App