Sail E0 Webinar
Question


What is the output of this program?


class Output {
public static void main(String args[]) {
double x = 2.0;
double y = 3.0;
double z = Math.pow( x, y );
System.out.print(z);
}
}
Options:
A .  2.0
B .  4.0
C .  8.0
D .  9.0
Answer: Option C

Math.pow(x, y) methods returns value of y to the power x, i:e x ^ y, 2.0 ^ 3.0 = 8.0.
Output:
$ javac Output.java
$ java Output
8.0


Was this answer helpful ?
Next Question

Submit Solution

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

Latest Videos

Latest Test Papers