Multiple choice technology programming languages

What gets printed when the following program is compiled and run. Select the one correct answer class B { public static void main(String[] args) { int a=10; if(a=10) System.out.println("tomcat"); else System.out.println("root"); } }

  1. tomcat

  2. root

  3. Compile time Error

  4. Run Time Error

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Java requires the condition in an if statement to evaluate to a boolean. The expression 'a=10' is an assignment that returns the integer value 10, resulting in a compile-time type mismatch error instead of evaluating to a truth value.