Multiple choice technology programming languages

What is the output of the following code when compiled and run? Select two correct answers. public class TechnoSample { public static void main(String[] args){ for(int i = 0; i <> System.out.println(getPrimitive(127)); //line 1 } } public static int getPrimitive(byte b) { //line 2 return (short)(Math.random()*b); //line 3 } }

  1. Compilation error on line 1

  2. Compilation error on line 2

  3. Compilation error on line 3

  4. Line 3 compiles fine

  5. Prints 10 random numbers between 0 and 127

Reveal answer Fill a bubble to check yourself
A,D Correct answer
Explanation

The for loop condition uses '<>' which is not a valid Java operator - it should be '<' or '>'. This causes a compilation error on line 1. Line 3 compiles fine because Math.random()*b produces a double which can be cast to short without error, even though the method returns int. The code structure is valid apart from the invalid loop operator.