- Home
- Java Programming MCQ
- Java MCQ - Introduction to Java
- Introduction to Java - Set 1
- Introduction to Java - Set 2
- Introduction to Java - Set 3
- Introduction to Java - Set 4
- Introduction to Java - Set 5
- Introduction to Java - Set 6
- Introduction to Java - Set 7
- Introduction to Java - Set 8
- Introduction to Java - Set 9
- Introduction to Java - Set 10
- Introduction to Java - Set 11
- Introduction to Java - Set 12
- Introduction to Java - Set 13
- Introduction to Java - Set 14
- Introduction to Java - Set 15
- Introduction to Java - Set 16
- Introduction to Java - Set 17
- Introduction to Java - Set 18
- Introduction to Java - Set 19
- Introduction to Java - Set 20
- Introduction to Java - Set 21
- Introduction to Java - Set 22
- Introduction to Java - Set 23
- Introduction to Java - Set 24
- Introduction to Java - Set 25
- Introduction to Java - Set 26
- Introduction to Java - Set 27
- Introduction to Java - Set 28
- Introduction to Java - Set 29
- Introduction to Java - Set 30
- Introduction to Java - Set 31
- Introduction to Java - Set 32
- Introduction to Java - Set 33
- Java MCQ - Loops, Decisions and Mathematical functions
- Loops, Decisions and Mathematical functions MCQ
- Loops, Decisions and Mathematical functions MCQ - Set 1
- Loops, Decisions and Mathematical functions MCQ - Set 2
- Loops, Decisions and Mathematical functions MCQ - Set 3
- Loops, Decisions and Mathematical functions MCQ - Set 4
- Loops, Decisions and Mathematical functions MCQ - Set 5
- Loops, Decisions and Mathematical functions MCQ - Set 6
- Loops, Decisions and Mathematical functions MCQ - Set 7
- Loops, Decisions and Mathematical functions MCQ - Set 8
- Java MCQ - Methods and Arrays
- Methods and Arrays MCQ
- Methods and Arrays MCQ - Set 1
- Methods and Arrays MCQ - Set 2
- Methods and Arrays MCQ - Set 3
- Methods and Arrays MCQ - Set 4
- Methods and Arrays MCQ - Set 5
- Methods and Arrays MCQ - Set 6
- Methods and Arrays MCQ - Set 7
- Methods and Arrays MCQ - Set 8
- Methods and Arrays MCQ - Set 9
- Java MCQ - Objects and Classes
- Objects and Classes MCQ
- Objects and Classes MCQ - Set 1
- Objects and Classes MCQ - Set 2
- Objects and Classes MCQ - Set 3
- Objects and Classes MCQ - Set 4
- Objects and Classes MCQ - Set 5
- Objects and Classes MCQ - Set 6
- Objects and Classes MCQ - Set 7
- Java MCQ - Objects Oriented Programming
- Java MCQ - Exception Handling, I/O, Abstract classes and Interfaces
- Java MCQ - JAVAFX basics and Event-driven programming and animations
- Java MCQ - JAVAFX UI controls and multimedia
- Java MCQ - Binary I/O ,Recursion and Generics
- Java MCQ - List, Stacks, Queues and Priority Queues
- Java MCQ - Sets and Maps
- Java MCQ - Concurrency
Java Programming Multiple Choice Questions (MCQ)
Introduction to Java - Multiple Choice Questions (MCQ) - Set 18
![]() Share with a Friend |
Multiple Choice Questions
Java - Introduction to Java - Multiple Choice Questions (MCQ) - Set 18
86. What will be the output of the following Java program?
class bitwise_operator
{
public static void main(String args[])
{
int var1 = 42;
int var2 = ~var1;
System.out.print(var1 + " " + var2);
}
}
A). 42 42 B). 43 43
C). 42 -43
D). 42 43
View Answer
Correct: C
87. What will be the output of the following Java program?
class bitwise_operator
{
public static void main(String args[])
{
int a = 3;
int b = 6;
int c = a | b;
int d = a & b;
System.out.println(c + " " + d);
}
}
A). 7 2 B). 7 7
C). 7 5
D). 5 2
Correct: A
88. What will be the output of the following Java program?
class leftshift_operator
{
public static void main(String args[])
{
byte x = 64;
int i;
byte y;
i = x << 2;
y = (byte) (x << 2)
System.out.print(i + " " + y);
}
}
A). 0 64 B). 64 0
C). 0 256
D). 256 0
View Answer
Correct: D
89. What will be the output of the following Java program?
class rightshift_operator
{
public static void main(String args[])
{
int x;
x = 10;
x = x >> 1;
System.out.println(x);
}
}
A). 10 B). 5
C). 2
D). 20
Correct: B
90. What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
int a = 1;
int b = 2;
int c = 3;
a |= 4;
b >>= 1;
c <<= 1;
a ^= c;
System.out.println(a + " " + b + " " + c);
}
}
A). 3 1 6 B). 2 2 3
C). 2 3 4
D). 3 3 6
View Answer
Correct: A
