-
What is the output of this program?
public class main_class_Example
{
public static void main(String args[])
{
int p = 10;
if (p == 10)
{
// int p = 20;
int q = 20;
System.out.println(q);
}
}
}
-
- 10
- 20
- 11
- 21
- 25
Correct Option: B
Two variables with the same name can’t be created so there is second variable q in a class.
output: 20