What does the following code print?
public class { public static void main(String[] args) { int x=5 ,y = 10; if (x>5 && y>=2) System.out.println("Class 1"); else if (x<14 || y>5) System.out.println(" Class 2"); else System.out.println(" Class 3"); }// end of main } // end of class.

Answer :

matthew3944

Answer:

It throws an error.

the public class needs a name.

like this:

public class G{ public static void main(String[] args) {

   int x=5 , y = 10;

   if (x>5 && y>=2) System.out.println("Class 1");

   else if (x<14 || y>5) System.out.println(" Class 2");

   else System.out.println(" Class 3"); }// end of main

   }

if you give the class a name and format it, you get:

Class 2

Explanation:

Other Questions