Class TestQuestion
Class TestQuestion
for(int q=1;q<=3;q++) {
if(p==q)
continue;
System.out.print(+p);
System.out.println(+q);
What will be the output when the preceding program is compiled and executed?
11
12
11
21
12
13
21
23
2)class TestQuestion {
if(a) {
System.out.println("false");
else {
System.out.println("true");
What will be the output when the preceding program is compiled and executed?
A. The program will display the output as: B. The program will generate compilation error.
False
C. The program will display the output as: D. The program will throw a runtime exception.
True
3)Jennie is a software developer in an MNC. In one of her projects she wrote a program as:
import java.util.*;
class TestQuestion {
System.out.println(s.nextInt());
System.out.println(s.nextInt());
System.out.println(s.next());
System.out.println(s.next());
s.close();
}
A. The program will display the output as: . The program will generate compilation error.
red
blue
C. The program will display the output as: D. The program will display the output as:
1 fish
2 fish
fish fish
fish fish
4)Jennie is a software developer in an MNC. In one of her projects, she wrote a program as:
import java.util.*;
class TestQuestion {
Boolean b2 = false;
if(b1.equals(b2))
System.out.println("equal");
else
System.out.println("not-equal");
What will be the output when the preceding program is compiled and executed?
A. The program will display the output as: B. The program will generate compilation error.
equal
C. The program will display the output as: D. The program will throw a runtime exception.
not‐equal
5)Jennie is a software developer in an MNC. In one of her projects, she wrote a program as:
class TestQuestion {
boolean b = (a==10)?true:false;
System.out.println(b);
return b;
System.out.println("pass");
What will be the output when the preceding program is compiled and executed?
A. The program will display the output as: B. The program will generate compilation error.
true
false
C. The program will display the output as: D. The program will throw a runtime exception.
Pass
6)Jaya is a software developer in an MNC. In one of her projects she wrote a program as:
class TestQuestion {
System.out.println(sum);
During compilation and execution of the preceding program, what will happen?
A. The program will compile and execute successfully, but no output will be shown.
B. The program will generate compilation error.
7)Hari is a software developer in an MNC. In one of his projects, he wrote a program as:
class TestQuestion {
System.out.println(+operation);
What will be the output when the preceding program is compiled and executed?
‐6
8)Maya is a software developer in an MNC. In one of her projects she wrote a program as:
class TestQuestion {
System.out.println(s[0] + s[1]);
}
What will be the output when the preceding program is run with the following command line argument:
>java TestQuestion 12 24
A. The program will display the output as: B. The program will generate compilation error.
36
C. The program will display the output as: D. The program will throw a runtime exception.
1224
9)Jyoti is a software developer in an MNC. In one of her projects she wrote a program as:
switch (len) {
What will be the output when the preceding program is compiled and executed?
A. The program will display the output as: B. The program will generate compilation error.
March
C. The program will display the output as: D. The program will throw a runtime exception.
January
boolean a;
boolean p = false;
boolean q = false;
if(a = p == q) {
System.out.println("equal");
else
System.out.println("not-equal");
What will be the output when the preceding code is compiled and executed?
A. The program will display the output as: B. The program will generate compilation error.
equal
C. The program will display the output as: D. The program will throw a runtime exception.
not‐equal
11)Imagine you are a software developer in ABC. Company and write the following program for your
project:
class BooleanRep {
if(status) {
What will happen when you compile and exceute the preceeding program?
12)Imagine during your preparation of the SCJP exam, you came across the following program:
class AssignRep {
short b1=2;
short b2=3;
System.out.println("Result= "+b3);
What will happen when you compile and exceute the preceeding program?
13)Dheeraj works as a Programmer in Kogent Solutions Inc. He writes the following program:
class MyQuestion {
int a = 10;
System.out.print("Welcome ");
System.out.print("to ");
What will happen when he tries to compile and execute the preceding program?
A. The program will display: Welcome B. The program will display: to Java
C. The program will display: Welcome to D. The program will generate compilation error
14)Ria works as a Programmer for TimeNet Inc. She writes the following program:
What will happen if she tries to execute the preceding program by writing the following command line
argument?
A. It will display the output as: B. It will display the output as:
456 6
C. It will throw a runtime exception. D. It will compile and execute but does not
15)Imagine you work as a programmer in the ABC Company. You write the following program:
public class A {
case ferari:
System.out.print("ferari ");
default case:
System.out.print("mercedez ");
case maruti:
System.out.print("maruti ");
What will happen when you try to compile and execute the preceding program?
A. It will produce the output as: B. It will produce the output as:
Feraari mercedez
16)Neha works as a programmer in the ABC Company and she has written the following program:
switch(i) {
What will be the output when the preceding programis compiled and executed?
int x= 0;
int y = 10;
do {
y--;
++x;
What will be the output when the preceding program is compiled and executed?
18)Imagine you work as a programmer in the ABC Company and you have written the following
program:
class Next {
int x=12;
x--;
System.out.print(x);
}}
What will be the output when the preceding program is compiled and executed?
class Test {
int x = 10;
do {
System.out.println(x--);
while(x>10);
How many times will the value of x be printed after compilation and execution of the preceding
program?
20)Imagine you work as a programmer in the ABC Company and you have written the following
program:
class Test {
System.out.println(i);
What will be the output after compilation and execution of the preceding program?
21)Imagine you work as a programmer in the ABC Company and you have written the following
program:
class Testing {
if(pi>3) {
System.out.print("pi is big");
else {
finally {
What will be the output after compilation and execution of the preceding program?
A. pi is big B. pi is not big C. Have a nice day D. Program will not compile successfully.
22)class FloatingPointRep {
System.out.println("Height= "+height);
What will happen when you compile and exceute the preceeding program?