Explore topic-wise MCQs in Testing Subject.

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

1.

What will be the output of the following PHP code ? <?php for ($x = -1; $x < 10;--$x) { print $x; } ?>

A. 123456789101112
B. 12345678910
C. 1234567891011
D. Infinite loop
Answer» E.
2.

What will be the output of the following PHP code ? <?php $x; for ($x = -3; $x < -5; ++$x) { print ++$x; } ?>

A. -3-4-5
B. -3-4
C. Infinite loop
D. No output
Answer» E.
3.

What will be the output of the following PHP code ? <?php for ($i++; $i == 1; $i = 2) print "In for loop "; print "After loop n"; ?>

A. In for loop
B. After for loop
C. In for loopAfter for loop
D. Infinite loop
Answer» D. Infinite loop
4.

What will be the output of the following PHP code ? <?php for (1; $i == 1; $i = 2) print "In for loop "; print "After loop n"; ?>

A. In for loop
B. After for loop
C. In for loopAfter for loop
D. Infinite loop
Answer» C. In for loopAfter for loop
5.

What will be the output of the following PHP code ? <?php for ($i == 2; ++$i == $i; ++$i) print "In for loop "; print "After loop n"; ?>

A. In for loopIn for loopIn for loopIn for loop infinitely
B. After for loopAfter for loopAfter for loop ..infinitely
C. In for loopAfter for loopIn for loopAfter for loopIn for loopAfter for loop ..infinitely
D. After for loop
Answer» B. After for loopAfter for loopAfter for loop ..infinitely
6.

What will be the output of the following PHP code ? <?php for ($x = 1; $x < 10; $x++) for ($y = 1; $y < 5; $y++) print "Hello"; ?>

A. Hello .36 times
B. Hello .45 times
C. Hello .50 times
D. Hello .40 times
Answer» B. Hello .45 times
7.

What will be the output of the following PHP code ? <?php switch($b) { case 2: print "hello"; break; case 1: print "hi"; break; } ?>

A. Hello
B. Hi
C. No output
D. Error
Answer» D. Error
8.

What will be the output of the following PHP code ? <?php for ($count = 1; $count != 20;$count++) { print $count; $count++; } ?>

A. Infinite
B. 123 .20
C. 1357 19
D. 13579 21
Answer» B. 123 .20
9.

What will be the output of the following PHP code ? <?php switch($b) { case 2: print "hello"; break; case b: print "hi"; break; } ?>

A. Hello
B. Hi
C. No output
D. Error
Answer» D. Error
10.

What will be the output of the following PHP code ? <?php while() { print "hi"; } ?>

A. Infinite loop
B. Hi
C. No output
D. Error
Answer» E.
11.

What will be the output of the following PHP code ? <?php do { print "hi"; } while(0); print "hello"; ?>

A. Infinite loop
B. Hihello
C. Hello
D. Error
Answer» C. Hello
12.

What will be the output of the following PHP code ? <?php $i = 0 while ($i < 3) { $i++; } print $i; ?>

A. 2
B. 3
C. 0
D. 1
Answer» C. 0
13.

What will be the output of the following PHP code ? <?php $i = 0 do { $i++; } while ($i < 3); print $i; ?>

A. 2
B. 3
C. 0
D. 1
Answer» C. 0
14.

What will be the output of the following PHP code ? <?php $i = 0 while ($i++) { print $i; } print $i; ?>

A. 0
B. Infinite loop
C. 01
D. 1
Answer» E.
15.

What will be the output of the following PHP code ? <?php $i = ""; while($i) { print "hi"; } print "hello"; ?>

A. Hello
B. Infinite loop
C. Hihello
D. Error
Answer» B. Infinite loop
16.

What will be the output of the following PHP code ? <?php $i = 0; while($i = 10) { print "hi"; } print "hello"; ?>

A. Hello
B. Infinite loop
C. Hihello
D. Error
Answer» C. Hihello
17.

What will be the output of the following PHP code ? <?php $i = ""; while ($i) { print "hi"; } while($i < 8) $i++; print "hello"; ?>

A. Hi is printed 8 times, hello 7 times and then hi 2 times
B. Hi is printed 10 times, hello 7 times
C. Hi is printed once, hello 7 times
D. Hi is printed once, hello 7 times and then hi 2 times
Answer» E.
18.

What will be the output of the following PHP code ? <?php $i = 5; while (--$i > 0 && ++$i) { print $i; } ?>

A. 54321111111 .infinitely
B. 555555555 infinitely
C. 54321
D. 5
Answer» B. 555555555 infinitely
19.

What will be the output of the following PHP code ? <?php for ($count = 1; $count < 20; $count++); print $count; ?>

A. 20
B. 19
C. 12345678910 .19
D. 12345678910 .1920
Answer» B. 19
20.

What will be the output of the following PHP code ? <?php for ($i = 0; $i < 5; $i++) { for(; $i < 5; $i++) print"i"; } ?>

A. Iiiii
B. Infinite loop
C. Iiiiiiiiiiiiiiiiiiiiiiiii
D. No output
Answer» B. Infinite loop
21.

What will be the output of the following PHP code ? <?php $a = "2"; switch ($a) { case 1: print "hi"; case 2: print "hello"; break; default: print "hi1"; } ?>

A. Hihellohi1
B. Hello
C. Hihi1
D. Hi1
Answer» C. Hihi1
22.

What will be the output of the following PHP code ? <?php $a = "1"; switch($a) { case 1: break; print "hi"; case 2: print "hello"; break; default: print "hi1"; } ?>

A. Hihellohi1
B. No output
C. Hihi1
D. Hi1
Answer» C. Hihi1
23.

What will be the output of the following PHP code ? <?php $a = "1"; $a = 1; $b = 1; switch($a) { case $a * $b: print "hi"; break; case $a / $b: print "hello"; break; default: print "hi1"; } ?>

A. Hihellohi1
B. Hi
C. Hihello
D. Hi1
Answer» C. Hihello
24.

What will be the output of the following PHP code ? <?php $a = 97; switch($a) { case "a": print "hi"; break; case 97: print "hello"; break; default: print "hi1"; } ?>

A. Hihellohi1
B. Hi
C. Hihello
D. Hello
Answer» E.
25.

What will be the output of the following PHP code ? <?php $b = 1; switch($b) { case 1.0: print "hi"; break; case 1: print "hello"; break; default: print "hi1"; } ?>

A. Hihellohi1
B. Hi
C. Hihello
D. Hello
Answer» B. Hi
26.

What will be the output of the following PHP code ? <?php const $b = 1; switch($b) { case 1: print "hi"; break; case 1: print "hello"; break; default: print "hi1"; } ?>

A. Error
B. Hi
C. Hihello
D. Hello
Answer» B. Hi
27.

What will be the output of the following PHP code ? <?php $b = 1; switch(print $b) { case 2: print "hello"; break; case 1: print "hi"; break; default: print "hi1"; } ?>

A. 1hello
B. 1hi
C. 1hi1
D. Error
Answer» C. 1hi1
28.

What will be the output of the following PHP code ? <?php $a = array("hi", "hello", "bye"); foreach ($a as $value) { if (count($a) == 2) print $value; } ?>

A. Hihellobye
B. Infinite loop
C. Hihello
D. No output
Answer» E.
29.

What will be the output of the following PHP code ? <?php $a = array("hi", "hello", "bye"); for (;count($a) < 5;) { if (count($a) == 3) print $a; } ?>

A. ArrayArrayArrayArrayArrayArray .infinitely
B. ( hi , hello , bye )( hi , hello , bye )( hi , hello , bye )( hi , hello , bye ) infinitely
C. hihellobyehihellobyehihellobyehihellobyehihellobyehihellobye ..infinitely
D. No output
Answer» B. ( hi , hello , bye )( hi , hello , bye )( hi , hello , bye )( hi , hello , bye ) infinitely
30.

What will be the output of the following PHP code ? <?php $a = 10; $b = 4; $c = fun(10,4); function fun($a,$b) { $b = 3; return $a - $b + $b - $a; } echo $a; echo $b; echo $c; ?>

A. 104
B. 410
C. 1400
D. 4100
Answer» D. 4100
31.

What will be the output of the following PHP code ? <?php $a = "$winner"; $b = "/$looser"; echo $a,$b; ?>

A. $winner/$looser
B. /$looser
C. /
D. $looser
Answer» D. $looser
32.

What will be the output of the following PHP code ? <?php $x = 5; $y = 10; function fun() { $GLOBALS['y'] = $GLOBALS['x'] + $GLOBALS['y']; } fun(); echo $y; ?>

A. 5
B. 10
C. 15
D. Error
Answer» D. Error
33.

What will be the output of the following PHP code ? <?php $x = 5; $y = 10; function fun() { $y = $GLOBALS['x'] + $GLOBALS['y']; } fun(); echo $y; ?>

A. 5
B. 10
C. 15
D. Error
Answer» C. 15
34.

What will be the output of the following PHP code ? <?php function fun() { $x = 0; echo $x; $x++; } fun(); fun(); fun(); ?>

A. 012
B. 123
C. 000
D. 111
Answer» D. 111
35.

What will be the output of the following PHP code ? <?php function fun() { static $x = 0; echo $x; $x++; } fun(); fun(); fun(); ?>

A. 012
B. 123
C. 111
D. Error
Answer» B. 123
36.

What will be the output of the following PHP code ? <?php static $x = 0; function fun() { echo $x; $x++; } fun(); fun(); fun(); ?>

A. 012
B. 123
C. Nothing
D. Error
Answer» D. Error
37.

What will be the output of the following PHP code ? <?php $x=0; function fun() { echo $GLOBALS['x']; $GLOBALS['x']++; } fun(); fun(); fun(); ?>

A. 000
B. 012
C. 123
D. Error
Answer» C. 123
38.

Which constructor will be called from the object created in the code below? class A { int i; A() { i=0; cout<<i; } A(int x=0) { i=x; cout<<I; } }; A obj1;

A. Default constructor
B. Parameterized constructor
C. Compile time error
D. Run time error
Answer» D. Run time error
39.

Which constructor will be called from the object obj2 in the following program? class A { int i; A() { i=0; } A(int x) { i=x+1; } A(int y, int x) { i=x+y; } }; A obj1(10); A obj2(10,20); A obj3;

A. A(int x)
B. A(int y)
C. A(int y, int x)
D. A(int y, int x)
Answer» D. A(int y, int x)
40.

What is we only create an object but don t call any constructor for it in java?

A. Implicit constructor will be called
B. Object is initialized to some null values
C. Object is not created
D. Object is created but points to null
Answer» E.
41.

Which of the conditional statements is/are supported by PHP?i) if statementsii) if-else statementsiii) if-elseif statementsiv) switch statements

A. Only i)
B. I), ii) and iv)
C. Ii), iii) and iv)
D. All of the mentioned.
Answer» E.
42.

Which of the looping statements is/are supported by PHP?i) for loopii) while loopiii) do-while loopiv) foreach loop

A. I) and ii)
B. I), ii) and iii)
C. All of the mentioned
D. None of the mentioned
Answer» D. None of the mentioned
43.

Choose the correct sequence of destructors being called for the following code: class A{ }; class B{ }; class C: public A, public B{ };

A. ~A(), ~B(), ~C()
B. ~B(), ~C(), ~A()
C. ~A(), ~C(), ~B()
D. ~C(), ~B(), ~A()
Answer» E.
44.

Which class destructor will be called first, when following code go out of scope? class A{ }; class B{ }; class C: public B{ }; A a; B b; C c;

A. ~A()
B. ~B()
C. ~C()
D. ~B() and ~C()
Answer» D. ~B() and ~C()
45.

Dot . operator in strings are called as

A. Assignment operator
B. Concatenation operator
C. Concatenating assignment operator
D. Literal operator
Answer» C. Concatenating assignment operator
46.

Which of the following is/are not an exception? i) BadFunctionCallException ii) BadMethodCallException iii) LogicException iv) DomainException

A. All of the mentioned
B. Only iv)
C. Iii) and iv)
D. None of the mentioned
Answer» E.
47.

Which of the following is/are an external data? i) Cookies ii) Input data from a form iii) Server Variables iv) Web services data

A. Only ii)
B. Ii) and iii)
C. None of the mentioned
D. All of the mentioned
Answer» E.
48.

Which of the following is/are an exception? i) OutOfBoundException ii) OutOfRangeException iii) OverflowException iv) UnderflowException

A. All of the mentioned
B. I) and iii)
C. I) and ii)
D. None of the mentioned
Answer» B. I) and iii)
49.

What will be the output of the following PHP code? <?php $num = "123"; if (!filter_var($num, FILTER_VALIDATE_INT)) echo("Integer is not valid"); else echo("Integer is valid"); ?>

A. No output is returned
B. Integer is not valid
C. Integer is valid
D. Error
Answer» D. Error
50.

What will be the output of the following PHP code? <?php $var=300; $int_options = array("options"=>array ("min_range"=>0, "max_range"=>256)); if (!filter_var($var, FILTER_VALIDATE_INT, $int_options)) echo("Integer is not valid"); else echo("Integer is valid"); ?>

A. No output is returned
B. Integer is not valid
C. Integer is valid
D. Error
Answer» C. Integer is valid