What is the value of “d” in the following Java code snippet?
double d = Math.round ( 2.5 + Math.random() );
a) 2
b) 3
c) 4
d) 2.5
Answer: b
Explanation: The Math.random() method returns a number greater than or equal to 0 and less than 1. so 2.5 will be greater than or equal to 2.5 and less than 3.5, we can be sure that Math.round() will round that number to 3.
Related Posts
Messages sent by a process __________
Which of the following two operations are provided by the IPC facility?
Message passing system allows processes to __________
What is Interprocess communication?
The child process completes execution, but the parent keeps executing, then the child process is known as __________
The child process can __________
In UNIX, the return value for the fork system call is _____ for the child process and _____ for the parent process.
Join The Discussion