Explore topic-wise MCQs in Technical Programming.

This section includes 1671 Mcqs, each offering curated multiple-choice questions to sharpen your Technical Programming knowledge and support exam preparation. Choose a topic below to get started.

1501.

Which of the following is a type of polymorphism in Java?

A. Compile time polymorphism
B. Execution time polymorphism
C. Multiple polymorphism
D. Multilevel polymorphism
Answer» B. Execution time polymorphism
1502.

Which of the following is not a valid flow control statement?

A. exit()
B. break
C. continue
D. return
Answer» B. break
1503.

From where break statement causes an exit?

A. Only from innermost loop
B. Terminates a program
C. Only from innermost switch
D. From innermost loops or switches
Answer» E.
1504.

Which of the following is not a valid jump statement?

A. break
B. goto
C. continue
D. return
Answer» C. continue
1505.

Which of the following is not a decision making statement?

A. if
B. if-else
C. switch
D. do-while
Answer» E.
1506.

What is the valid data type for variable “a” to print “Hello World”? switch(a) { System.out.println("Hello World"); }

A. int and float
B. byte and short
C. char and long
D. byte and char
Answer» E.
1507.

Which of the following is used with switch statement?

A. Continue
B. Exit
C. break
D. do
Answer» D. do
1508.

What is true about do statement?

A. do statement executes the code of a loop at least once
B. do statement does not get execute if condition is not matched in the first iteration
C. do statement checks the condition at the beginning of the loop
D. do statement executes the code more than once always
Answer» B. do statement does not get execute if condition is not matched in the first iteration
1509.

What is true about break?

A. Break stops the execution of entire program
B. Break halts the execution and forces the control out of the loop
C. Break forces the control out of the loop and starts the execution of next iteration.
D. Break halts the execution of the loop for certain time frame
Answer» C. Break forces the control out of the loop and starts the execution of next iteration.
1510.

The while loop repeats a set of code while the condition is not met?

A. True
B. False
Answer» C.
1511.

What would be the output of the following codesnippet if variable a=10? if(a<=0) { if(a==0) { System.out.println("1 "); } else { System.out.println("2 "); } } System.out.println("3 ");

A. 1 2
B. 2 3
C. 1 2
D. 3
Answer» E.
1512.

What is the output of this program? class Output { public static void main(String args[]) { int a = 5; int b = 10; first: { second: { third: { if (a == b >> 1) break second; } System.out.println(a); } System.out.println(b); } } }

A. 5 10
B. 10 5
C. 5
D. 10
Answer» E.
1513.

What is the output of this program? class Output { public static void main(String args[]) { final int a=10,b=20; while(a

A. Hello
B. run time error
C. Hello world
D. compile time error
Answer» E.
1514.

What is the output of this program? class jump_statments { public static void main(String args[]) { int x = 2; int y = 0; for ( ; y < 10; ++y) { if (y % x == 0) continue; else if (y == 8) break; else System.out.print(y + " "); } } }

A. 1 3 5 7
B. 2 4 6 8
C. 1 3 5 7 9
D. 1 2 3 4 5 6 7 8 9
Answer» D. 1 2 3 4 5 6 7 8 9
1515.

What is the output of this program? class comma_operator { public static void main(String args[]) { int sum = 0; for (int i = 0, j = 0; i < 5 & j < 5; ++i, j = i + 1) sum += i; System.out.println(sum); } }

A. 5
B. 6
C. 14
D. compilation error
Answer» C. 14
1516.

What is the output of this program? class selection_statements { public static void main(String args[]) { int var1 = 5; int var2 = 6; if ((var2 = 1) == var1) System.out.print(var2); else System.out.print(++var2); } }

A. 1
B. 2
C. 3
D. 4
Answer» C. 3
1517.

Which of these statement is incorrect?

A. switch statement is more efficient than a set of nested ifs
B. two case constants in the same switch can have identical values
C. switch statement can only test for equality, whereas if statement can evaluate any type of boolean expression
D. it is possible to create a nested switch statements
Answer» C. switch statement can only test for equality, whereas if statement can evaluate any type of boolean expression
1518.

Which of these jump statements can skip processing remainder of code in its body for a particular iteration?

A. break
B. return
C. exit
D. continue
Answer» E.
1519.

Which of these are selection statements in Java?

A. if()
B. for()
C. continue
D. break
Answer» B. for()
1520.

Which of these selection statements test only for equality?

A. if
B. switch
C. if & switch
D. none of the mentioned
Answer» C. if & switch
1521.

What is the output of this program? class Output { public static void main(String args[]) { int a,b,c,d; a=b=c=d=20 a+=b-=c*=d/=20 System.out.println(a+" "+b+" "+c+" "+d); } }

A. compile time error
B. runtime error
C. a=20 b=0 c=20 d=1
D. none of the mentioned
Answer» D. none of the mentioned
1522.

Which of these lines of code will give better performance? 1. a | 4 + c >> b & 7; 2. (a | ((( 4 * c ) >> b ) & 7 ))

A. 1 will give better performance as it has no parentheses.
B. 2 will give better performance as it has parentheses.
C. Both 1 & 2 will give equal performance.
D. Dependent on the computer system.
Answer» D. Dependent on the computer system.
1523.

What is the output of this program? class Output { public static void main(String args[]) { int x=y=z=20; } }

A. compile and runs fine
B. 20
C. run time error
D. compile time error
Answer» E.
1524.

What is the output of this program? class operators { public static void main(String args[]) { int x = 8; System.out.println(++x * 3 + " " + x); } }

A. 24 8
B. 24 9
C. 27 8
D. 27 9
Answer» E.
1525.

What is the output of this program? class operators { public static void main(String args[]) { int var1 = 5; int var2 = 6; int var3; var3 = ++ var2 * var1 / var2 + var2; System.out.print(var3); } }

A. 10
B. 11
C. 12
D. 56
Answer» D. 56
1526.

What is the order of precedence (highest to lowest) of following operators? 1. & 2. ^ 3. ?:

A. 1 -> 2 -> 3
B. 2 -> 1 -> 3
C. 3 -> 2 -> 1
D. 2 -> 3 -> 1
Answer» B. 2 -> 1 -> 3
1527.

What is the value stored in x in following lines of code? int x, y, z; x = 0; y = 1; x = y = z = 8

A. 0
B. 1
C. 9
D. 8
Answer» E.
1528.

What should be expression1 evaluate to in using ternary operator as in this line? expression1 ? expression2 : expression3

A. Integer
B. Floating – point numbers
C. Boolean
D. None of the mentioned
Answer» D. None of the mentioned
1529.

Which of these have highest precedence?

A. ()
B. ++
C. *
D. >>
Answer» B. ++
1530.

What is the output of this program? class Output { public static void main(String args[]) { boolean a = true; boolean b = false; boolean c = a ^ b; System.out.println(!c); } }

A. 0
B. 1
C. False
D. True
Answer» D. True
1531.

What is the output of this program? class Output { public static void main(String args[]) { int x , y = 1; x = 10; if (x != 10 && x / 0 == 0) System.out.println(y); else System.out.println(++y); } }

A. 1
B. 2
C. Runtime error owing to division by zero in if condition
D. Unpredictable behavior of program
Answer» C. Runtime error owing to division by zero in if condition
1532.

What is the output of this program? class ternary_operator { public static void main(String args[]) { int x = 3; int y = ~ x; int z; z = x > y ? x : y; System.out.print(z); } }

A. 0
B. 1
C. 3
D. -4
Answer» D. -4
1533.

What is the output of this program? class bool_operator { public static void main(String args[]) { boolean a = true; boolean b = !true; boolean c = a | b; boolean d = a & b; boolean e = d ? b : c; System.out.println(d + " " + e); } }

A. false false
B. true ture
C. true false
D. false true
Answer» E.
1534.

What is the output of this program? class Relational_operator { public static void main(String args[]) { int var1 = 5; int var2 = 6; System.out.print(var1 > var2); } }

A. 1
B. 0
C. True
D. False
Answer» E.
1535.

Which of these statement is correct?

A. true and false are numeric values 1 and 0
B. true and false are numeric values 0 and 1
C. true is any non zero value and false is 0
D. true and false are non numeric values
Answer» E.
1536.

Which of these operators can skip evaluating right hand operand?

A. !
B. I
C. &
D. &&
Answer» E.
1537.

Which of the following operators can operate on a boolean variable? 1. && 2. == 3. ?: 4. +=

A. 3 & 2
B. 1 & 4
C. 1, 2 & 4
D. 1, 2 & 3
Answer» E.
1538.

Which of these is returned by “greater than”, “less than” and “equal to” operators?

A. Integers
B. Floating – point numbers
C. Boolean
D. None of the mentioned
Answer» D. None of the mentioned
1539.

What is the output of relational operators?

A. Integer
B. Boolean
C. Characters
D. Double
Answer» C. Characters
1540.

What is the output of this 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
Answer» B. 2 2 3
1541.

What is the output of this 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
Answer» C. 2
1542.

What is the output of this 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
Answer» E.
1543.

What is the output of this 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
Answer» B. 7 7
1544.

What is the output of this 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
Answer» D. 42 43
1545.

Which of these statements are incorrect?

A. The left shift operator, <<, shifts all of the bits in a value to the left specified number of times
B. The right shift operator, >>, shifts all of the bits in a value to the right specified number of times
C. The left shift operator can be used as an alternative to multiplying by 2
D. The right shift operator automatically fills the higher order bits with 0
Answer» E.
1546.

Which right shift operator preserves the sign of the value?

A. <<
B. >>
C. <<=
D. >>=
Answer» C. <<=
1547.

On applying Left shift operator, <<, on an integer bits are lost one they are shifted past which position bit?

A. 1
B. 32
C. 33
D. 31
Answer» E.
1548.

Which operator is used to invert all the digits in binary representation of a number?

A. ~
B. <<<
C. >>>
D. ^
Answer» B. <<<
1549.

Which of these is not a bitwise operator?

A. &
B. &=
C. |=
D. <=
Answer» E.
1550.

What is the output of this program? class Output { public static void main(String args[]) { int a = 1; int b = 2; int c; int d; c = ++b; d = a++; c++; b++; ++a; System.out.println(a + " " + b + " " + c); } }

A. 3 2 4
B. 3 2 3
C. 2 3 4
D. 3 4 4
Answer» E.