Topics Index

Search student details2404

If you need explanation Read this topic

If you need Answer Take test on this topic

Search student details2404
What will be the output of the following program?
public class Search {
    public static void main(String[] args) {
        double attendance = 99.01;
        float percentage = 75.02f;
        double gateScore = -13.99;
        double searchResult = 0.12;
        System.out.println("Search result in sec " + Math.floor(searchResult));
        System.out.println("Attendance " + Math.floor(attendance));
        System.out.println("Percentage " + Math.floor(percentage));
        System.out.println("GATE Score " + Math.floor(gateScore));

A. Search result in sec 0.1
Attendance 99.0
Percentage 75.0
GATE Score -13.0
B. Search result in sec 1.0
Attendance 100.0
Percentage 76.0
GATE Score -13.0
C. Search result in sec 0.0
Attendance 99.0
Percentage 75.0
GATE Score -14.0
D. Compilation Error
E. Runtime Error
Topic: Java Math Class - java.lang.Math

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 C as searchResult is 0.12 it is double variable and is printed as 0.0 similarly all variables are printed as follows

Posted by Bharath Yelchuri    2014-04-29 13:02:58

Ans is C Math.flloor method Returns the largest integer that is less than or equal to the argument(double,float etc). Returned as a double,float as declared as variables so it prints the values as as 0.0,99.0,75.0,-14.0

Posted by Naga Sinst    2014-04-29 13:08:05

C....Math.floor mthd gives largest double value which should be an  integer..

Posted by Manaswini Panuganti    2014-04-29 13:17:59

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

Posted by Merit Campus    2014-04-30 04:11:56

© meritcampus 2019

All Rights Reserved.

Open In App