Java
T
point
Home
Python
Java
JavaScript
HTML
SQL
PHP
C#
C++
DS
Aptitude
Reasoning
Selenium
DBMS
C
Android
Interview Q
Content Menu ▼
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Question 1
:
What will be the result of executing the following code?
public static void main(String args[])
{
char digit = 'a';
for (int i = 0; i < 10; i++)
{
switch (digit)
{
case 'x' :
{
int j = 0;
System.out.println(j);
}
default :
{
int j = 100;
System.out.println(j);
}
}
}
int i = j;
System.out.println(i);
}
1.
100 will be printed 11 times.
2.
100 will be printed 10 times and then there will be a runtime exception.
3.
The code will not compile because the variable i cannot be declared twice within the main() method.
4.
None of these.