Sail E0 Webinar
Question


What is the output of this program?


class Output {
public static void main(String args[]) {
Double i = new Double(257.578);
int x = i.intValue();
System.out.print(x);
}
}
Options:
A .  0
B .  1
C .  256
D .  257
Answer: Option D

i.intValue() method returns the value of wrapper i as a Integer. i is 257.578 is double 

number when converted to an integer data type its value is 257.
Output:
$ javac Output.java
$ java Output
257



Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers