What is the possible output from System.out.println((int)(Math.random() * 4))?

a. 0
b. 1
c. 2
d. 3
e. 4

abcd Math.random() returns a real value between 0.0 and 1.0, excluding 1.0 . Math.random() * 4 yields a real value between 0.0 and 4.0, excluding 4.0 . After casting, the resulting integer may be 0, 1, 2, or 3.

Computer Science & Information Technology

You might also like to view...

A constructor is a method named __________ found inside the class.

a. New b. Constructor c. Finalizer d. the same as the class name

Computer Science & Information Technology

In a(n) _____ structure, which usually is based on interpersonal relationships, some people have more influence or knowledge than appears on an organization chart.

A. spontaneous B. unstructured C. informal D. open-ended

Computer Science & Information Technology