You are on page 1of 3

Quiz

OOP(Control Statements) Marks:15


Time:15 Mins Date: 10/10/2019

A:
Public class Test {
Public static void main(String[] args)
{
for (int i = 0, String = "GFG"; i < 2; i++)
System.out.println("HELLO GEEKS");
}
}
1. HELLO GEEKS
2. Compile time error
3. HELLO GEEKS
HELLO GEEKS
HELLO GEEKS
4. No Output

B:
Public class Test {
Public static void main(String[] args)
{
int i = 0;
for (System.out.println("HI"); i < 1; i++)
System.out.println("HELLO GEEKS");
}
}
1. HI
HELLO GEEKS
2. No Output
3. Compile time error
4. HELLO GEEKS
C:
Public class Test {
public
static void main(String[] args)
{
for (int i = 0;; i++)
System.out.println("HELLO GEEKS");
}
}
1. Compile time error
2. HELLO GEEKS
3. HELLO GEEKS (Infinitely)
4. Run-time Exception
D:
Public class Test {
Public static void main(String[] args)
{
for (int i = 0; i < 1; System.out.println("WELCOME"))
System.out.println("GEEKS");
}
}

1.GEEKS
WELCOME
GEEKS
WELCOME
2.No Output
3.Compile time error
4.GEEKS WELCOME(Infinitely)
E:
class Test {
public static void main(String[] args)
{
int i = 0, j = 9;
do {
i++;
if (j-- < i++) {
break;
}
} while (i < 5);
System.out.println(i + "" + j);
}
}
1.44
2.55
3.66
4.77
F:
class Test {
public
static void main(String[] args)
{
int j = 0;
do

for (int i = 0; i++ < 1


System.out.println(i);
while (j++ < 2);
}
}

1. 111
2. 222
3. 333
4. error
G:
class Test {
public static void main(String[] args)
{
int x = 10;
if (++x < 10 && (x / 0 > 10)) {
System.out.println("Bishal");
} else {
System.out.println("GEEKS");
}
}
}
1.Compile time error
2. RuntimeException:ArithmeticException: / by zero
3. Bishal
4. GEEKS
H:
class Test {
public static void main(String[] args)
{
final int a = 10, b = 20;
while (a > b) {
System.out.println("Hello");
}
System.out.println("GEEKS");
}
}
1. Compile time error
2. GEEKS
3. Hello
4. No Output

You might also like