Menu
Topics Index
...
`

Test result


If you need explanation Read this topic

If you need Answer Take test on this topic

Test result
What will be the output of the following program?
public class Test {
    public static void main(String[] args) {
        int marks = 72;
        float percentage = 72f;
        Boolean status = (marks >= 70);
        System.out.printf("Pass %b%npercentage %f", status, percentage);
    }
}

A. Pass true
percentage 72.000000
B. Pass true
percentage 72.0
C. Compilation Error
D. 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 c, actual n formal arguments length is difer

Posted by Uday Kumar    2014-01-29 03:41:55


ans is a because printf prints formatted output with %b and %f are format strings

Posted by Akash Kolariya    2014-01-29 03:42:54


ans is c...

Posted by Kick Bhasha    2014-01-29 04:15:03


ans is: A, here '%n' is treated as new line so output is displayed in two lines. And %b , %f represents boolean and float types respectively.

Posted by Mallikarjuna Rao    2014-01-29 04:38:49


ans "c"

Posted by Rolly Singh    2014-01-29 06:02:14


Ans is A as here in the body of program the expected o/p is 'Pass' followed by status of the boolean (true) followed by new line (\n) and as float is selected it takes 6 zeros after the percentage. Thus the output is same as option 'A'.

Posted by Jigar Mehta    2014-01-29 07:06:14


A

Posted by Kishan Viru    2014-01-29 07:42:51


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

Posted by Merit Campus    2014-01-30 04:26:09


© meritcampus 2019

All Rights Reserved.

Open In App