Menu
Topics Index
...
`

Print discount


If you need explanation Read this topic

If you need Answer Take test on this topic

Print discount
What will be the output of the following program?
import java.util.*;
public class Discount {
    public static void main(String[] args) {
        String output;
        Formatter convert = new Formatter();
        convert.format("Quantity %o,discount %%%d ", 6, 25);
        output = convert.toString();
        System.out.println(output);
    }
}

A. Quantity 6,discount %25
B. Quantity 6,discount %25.00
C. Some other output
D. Compilation Error
E. Runtime Error
Topic: Java Formatter

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

Posted by Adithya Aleti    2014-04-28 03:48:07


ans is A bec string.format() is similar to System.out.print stmt so covert is changed to sting ie output and printed.%o is octal print so 6 since(%o is given as 6) is printed %%%d value will be%25

Posted by Teja Sri Arikati    2014-04-28 04:53:05


ans is A

Posted by Meghana Trikovala    2014-04-28 06:29:04


ans is A

Posted by Meghana Trikovala    2014-04-28 06:29:04


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

Posted by Merit Campus    2014-04-29 04:09:37


© meritcampus 2019

All Rights Reserved.

Open In App