Questions
Question 1 Multiple Choice (Single Answer)
What is the output of the given program?
public class HelloWorld {
public static void main(String[] args) {
String s1 = "Welcome to Aliensbrain";
String s2 = "Welcome to Aliensbrain";
switch (s1 == s2) {
default: System.out.println("Bye");
case 1:
System.out.println("Hello Italy");
case 0:
System.out.println("Hello Paris");
}
}
}
- Hello ItalyHello Paris
- Hello Paris
- Bye Hello ItalyHello Paris
- Compiler Error
- Run time exception
Question 2 Multiple Choice (Single Answer)
What is the output of the given code?
public class HelloWorld {
public static void main(String[] args) {
int i = 128 << 2 << 1 << 0;
switch (i) {
default: System.out.println("Bye");
case 128 << 4 << 3 << 2 >> 6:
System.out.println("Hello Italy");
case 128 << 4 << 2 << 2 >> 6:
System.out.println("Hello Paris");
case 128 << 4 << 4 << 2 >> 3:
System.out.println("Hello London");
}
}
}
- ByeHello ItalyHello ParisHello London
- Hello ItalyHello ParisHello London
- Hello ParisHello London
- Hello London
- Compiler error
Question 3 Multiple Choice (Single Answer)
Which of the following is not the method of the scanner class object in Java?
- Next()
- nextLine()
- nextInt()
- nextChar()
- nextLong()
Question 4 Multiple Choice (Single Answer)
What is the output of the given program?
public class HelloWorld {
public static void main(String[] args) {
int x = 24;
int y = 42;
int z = 37;
int a = 22;
System.out.println(x & y | z ^ a);
}
}
- 60
- 59
- 58
- 57
- 56
Question 5 Multiple Choice (Single Answer)
What is the output of the given program?
public class HelloWorld {
public static void main(String[] args) {
int x = 24;
int y = 42;
System.out.println((~x) | (~y));
}
}
- - 25
- - 43
- - 9
- - 6
- Compiler error
Question 6 Multiple Choice (Single Answer)
What is the output of the given code?
public class HelloWorld {
public static void main(String[] args) {
int x = 24;
int y = 42;
int z = 37;
int a = 22;
System.out.println(x & y ^ z | x~a);
}
}
- 63
- -63
- 74
- -74
- Compiler error
Question 7 Multiple Choice (Single Answer)
What is the output of the given program?
public class Example {
public static void main(String[] args) {
String s1 = "Welcome to Aliensbrain";
String s2 = "Welcome to Aliensbrain";
if (s1 == s2) // Line 1
System.out.println("Equal");
else System.out.println("Not Equal");
}
}
- Equal
- Not Equal
- Run time error
- Blank output screen
- Error at line 1
Question 8 Multiple Choice (Single Answer)
What is the output of the given program?
public class Example {
public static void main(String[] args) {
String s1 = new String("Welcome to Aliensbrain");
String s2 = new String("Welcome to Aliensbrain");
String s3 = new String("Welcome to Aliensbrain");
if (s3 == (s1 == s2)) // Line 1
System.out.println("Equal");
else
System.out.println("Not Equal");
}
}
- Equal
- Not equal
- Blank output
- Error at line 1
- Run time error
Question 9 Multiple Choice (Single Answer)
What is the output of the given code?
public class HelloWorld {
public static void main(String[] args) {
int x = 24;
int y = 42;
int z = 37;
int a = 22;
System.out.println(x | y | z | a);
}
}
- 64
- 59
- 62
- 63
- 77
Question 10 Multiple Choice (Single Answer)
What is the output of the given program?
public class Example {
public static void main(String[] args) {
String s1 = new String("Welcome to Aliensbrain");
String s2 = new String("Welcome to Aliensbrain");
if (s1 == s2) // Line 1
System.out.println("Equal");
else
System.out.println("Not Equal");
}
}
- Equal
- Not Equal
- Blank screen
- Error at line 1
- Run time error
Question 11 Multiple Choice (Single Answer)
What is the output of the given code?
public class HelloWorld {
public static void main(String[] args) {
int i = 128 << 4 << 3 << 2 >> 6;
switch (i) {
default: System.out.println("Bye");
case 65536:
System.out.println("Hello Italy");
case 32:
System.out.println("Hello Paris");
case 8 / 2:
System.out.println("Hello London"); //Line 1
}
}
}
- Hello ItalyHello ParisHello London
- Bye
- ByeHello ItalyHello ParisHello London
- Hello ParisHello London
- Error at line 1
Question 12 Multiple Choice (Single Answer)
What is the output of the given program?
public class MyClass {
public static void main(String[] args) {
System.out.println(128 >> 4 >> 3 >> 2); //Line 1
}
}
- 2
- 4
- 0
- Divide by zero exception
- Error at line 1
Question 13 Multiple Choice (Single Answer)
What is the output of the given program?
public class Example {
public static void main(String[] args) {
System.out.println(128 << 4 << 3 << 2 >> 6); // Line 1
}
}
- 65536
- 1024
- 0
- Divide by zero exception
- Error at line 1