-
What would be the output of the following codesnippet if variable p=20?
public class Result
{
public static void main(String args[])
{
int p=20;
if(p<=0)
{
if(p==0)
{
System.out.println("5 ");
}
else
{
System.out.println("10 ");
}
}
System.out.println("15 ");
}
}
-
- 10
- 50
- 15
- 20
- 30
Correct Option: C
Since the first if condition is not met, control would not go inside if statement and hence only statement after the entire if block will be executed.