viewing paste Unknown #27574 | Text

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
Here is a method that returns a random String (in the form of symbolic constants defined elsewhere):
 
   public static String randString()
   {
      int testNum;
     
      testNum = (int)(Math.random() * 5000);
     
      if ( testNum > 4600 )
         return BAR;
      else if ( testNum > 3000 )
         return CHERRIES;
      else if ( testNum > 1200 )
         return SPACE;
      else  
         return SEVEN;
   }
If this method were called from a program many times, the following lists the Strings that we would expect it to return, ordered from the most frequently returned Strings (top of list) to least frequently returned Strings (bottom of list),
 
(Check the one that fits this description.)
 
        A.      SPACE
CHERRIES
BAR
SEVEN
        B.      SEVEN
SPACE
CHERRIES
BAR
        C.      BAR
CHERRIES
SPACE
SEVEN
        D.      BAR
SEVEN
CHERRIES
SPACE
        E.      SPACE
CHERRIES
SEVEN
BAR
        F.      SEVEN
BAR
CHERRIES
SPACE
 
Viewed 516 times, submitted by unknown.