Java OCA OCP Practice Question 1883

Question

Identify valid for constructs...

Assume that Math.random() returns a double between 0.0 and 1.0 (not including 1.0).

Select 3 options

A.  for (;Math .random ()<0.5;){
        System.out.println ("true");
    }//from   w ww  .jav  a2s. c  o  m
B.  for (;;Math .random ()<0.5){
        System.out.println ("true");
    }
C.  for (;;Math .random ()){
        System.out.println ("true");
    }
D.  for (;;){
        Math .random ()< .05? break  : continue;
    }
E.  for (;;){
        if (Math .random ()< .05) break;
    }


Correct Options are  : A C E

Note

The three parts of a for loop are independent of each other.




PreviousNext

Related