-
What is the output of this program?
public class Result
{
public static void main(String args[])
{
int p , q = 2;
p = 20;
if (p != 20 && p / 0 == 0)
{
System.out.println(q);
}
else
{
System.out.println(++q);
}
}
}
-
- 1
- 2
- 3
- 4
- 5
Correct Option: C
Operator short circuit and, &&, skips evaluating right hand operand if left hand operand is false thus division by zero in if condition does not give an error.
output: 3