-
What is the output of this program?
public class selection_statement_Example
{
public static void main(String args[])
{
int num1 = 10;
int num2 = 20;
if ((num2 = 5) == num1)
{
System.out.print(num2);
}
else
{
System.out.print(++num2);
}
}
}
-
- 5
- 4
- 6
- 7
- 5
Correct Option: C
num2 is initialised to 5. The conditional statement returns false and the else part gets executed.
output: 6