Explore topic-wise MCQs in Technical Programming.

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

251.

How many error levels are available in PHP?

A. 14
B. 15
C. 16
D. 17
Answer» D. 17
252.

Which magic method is used to implement overloading in PHP?

A. __call
B. __invoke
C. __wakeup
D. __unset
Answer» B. __invoke
253.

Which feature allows us to call more than one method or function of the class in single instruction?

A. Typecasting
B. Method Including
C. Method adding
D. Method chaining
Answer» E.
254.

Which method is used to tweak an object’s cloning behavior?

A. clone()
B. __clone()
C. _clone
D. _clone
Answer» C. _clone
255.

If your object must inherit behavior from a number of sources you must use a/an

A. Interface
B. Object
C. Abstract class
D. Static class
Answer» B. Object
256.

If one intends to create a model that will be assumed by a number of closely related objects, which class must be used?

A. Normal class
B. Static class
C. Abstract class
D. Interface
Answer» D. Interface
257.

Which of the following is/are true for an abstract class? i) A class is declared abstract by prefacing the definition with the word abstract. ii) A class is declare abstract by using the keyword implements. iii) It is a class that really isn’t supposed to ever be instantiated but instead serves as a base class. iv) Attempting to instantiate an abstract class results in an error.

A. Only ii)
B. All of the mentioned
C. ii) and iv)
D. ii), iii) and iv)
Answer» B. All of the mentioned
258.

The class from which the child class inherits is called.. i) Child class ii) Parent class iii) Super class iv) Base class

A. Only i)
B. ii), iii) and iv)
C. Only iii)
D. ii) and iv)
Answer» E.
259.

Which one of the following is the right way to clone an object?

A. _clone(targetObject);
B. destinationObject = clone targetObject;
C. destinationObject = _clone(targetObject);
D. destinationObject = clone(targetObject);
Answer» C. destinationObject = _clone(targetObject);
260.

Which version of PHP introduced the advanced concepts of OOP?

A. PHP 4
B. PHP 4
C. PHP 5.3
D. PHP 6
Answer» C. PHP 5.3
261.

Which of the following advanced OOP features is/are not supported by PHP? i) Method overloading ii) Multiple Inheritance iii) Namespaces iv) Object Cloning

A. All of the mentioned
B. None of the mentioned
C. i) and ii)
D. iii) and iv)
Answer» D. iii) and iv)
262.

Which keyword allows class members (methods and properties) to be used without needing to instantiate a new instance of the class?

A. protected
B. final
C. static
D. private
Answer» D. private
263.

In the PHP code given below, what is/are the properties?

A. echo “This is an example”
B. public $name;
C. class Example
D. function sample()
Answer» C. class Example
264.

Which one of the following functions is used to determine whether a class exists?

A. exist()
B. exist_class()
C. class_exist()
D. __exist()
Answer» D. __exist()
265.

Which version of PHP introduced the instanceof keyword?

A. PHP 4
B. PHP 5
C. PHP 5.3
D. PHP 6
Answer» C. PHP 5.3
266.

PHP recognizes constructors by the name_________

A. classname()
B. _construct()
C. function _construct()
D. function __construct()
Answer» E.
267.

Which of the following statements is/are true about Constructors in PHP? i) PHP 4 introduced class constructors. ii) Constructors can accept parameters. iii) Constructors can call class methods or other functions. iv) Class constructors can call on other constructors.

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

Which method scope prevents a method from being overridden by a subclass?

A. Abstract
B. Protected
C. Final
D. static
Answer» D. static
269.

Which of the following method scopes is/are not supported by PHP? i) private ii) final iii) static iv) abstract

A. Only ii)
B. Only iv)
C. ii) and iv)
D. None of the mentioned
Answer» E.
270.

Which of the following is/are the right way to declare a method?

A. function functionName() { function body }
B. scope function functionName() { function body }
C. method methodName() { method body }
D. scope method methodName() { method body }
Answer» D. scope method methodName() { method body }
271.

Which one of the following is the right way to invoke a method?

A. $object->methodName();
B. object->methodName();
C. object::methodName();
D. $object::methodName();
Answer» B. object->methodName();
272.

Which one of the following is the right way to call a class constant, given that the class is mathFunction?

A. echo PI;
B. echo mathFunction->PI;
C. echo mathFunction::PI;
D. echo mathFunction=PI;
Answer» D. echo mathFunction=PI;
273.

Which one of the following is the right way to define a constant?

A. constant PI = “3.1415”;
B. const $PI = “3.1415”;
C. const $PI = “3.1415”;
D. const PI = ‘3.1415’;
Answer» E.
274.

Which one of the following property scopes is not supported by PHP?

A. friendly
B. final
C. public
D. static
Answer» B. final
275.

The practice of creating objects based on predefined classes is often referred to as..

A. class creation
B. object creation
C. object instantiation
D. class instantiation
Answer» E.
276.

Which of the following term originates from the Greek language that means “having multiple forms,” defines OOP’s ability to redefine, a class’s characteristics?

A. Abstraction
B. Polymorphism
C. Inheritance
D. Differential
Answer» C. Inheritance
277.

The practice of separating the user from the true inner workings of an application through well-known interfaces is known as _________

A. Polymorphism
B. Inheritance
C. Encapsulation
D. Abstraction
Answer» D. Abstraction
278.

What will be the output of the following PHP code?

A. Array ( [0] => KA [1] => LA [2] => CA [3] => MA [4] => TA [5] => IA [6] => GA )
B. Array ( [0] => KA [2] => CA [4] => TA )
C. Array ( [1] => IA [3] => GA )
D. Array ( [1] => LA [3] => MA )
Answer» C. Array ( [1] => IA [3] => GA )
279.

What will be the output of the following PHP code?

A. 4hello2
B. 4
C. 2
D. 6
Answer» E.
280.

What will be the output of the following PHP code?

A. Error
B. Array ( [0] => apple [1] => mango [2] => peach )
C. Array ( [0] => apple [1] => mango )
D. Array ( [0] => pear [1] => orange )
Answer» D. Array ( [0] => pear [1] => orange )
281.

What will be the output of the following PHP code?

A. Array ( [0] => peach )
B. Array ( [0] => apple [1] => mango [2] => peach )
C. Array ( [0] => apple [1] => mango )
D. Array ( [0] => peach [1] => pear [2] => orange )
Answer» E.
282.

What will be the output of the following PHP code?

A. Array ( [0] => A [1] => J [2] => Q [3] => K [4] => 2 [5] => 3 [6] => 4 [7] => 5 [8] => 6 [9] => 7 [10] => 8 [11] => 9 [12] => 10 )
B. Array ( [0] => A [1] => 2 [2] => J [3] => 3 [4] => Q [5] => 4 [6] => K [7] => 5 [8] => 6 [9] => 7 [10] => 8 [11] => 9 [12] => 10 )
C. Error
D. Array ( [0] => 2 [1] => 3 [2] => 4 [3] => 5 [4] => 6 [5] => 7 [6] => 8 [7] => 9 [8] => 10 [9] => A [10] => J [11] => Q [12] => K )
Answer» B. Array ( [0] => A [1] => 2 [2] => J [3] => 3 [4] => Q [5] => 4 [6] => K [7] => 5 [8] => 6 [9] => 7 [10] => 8 [11] => 9 [12] => 10 )
283.

Say in the above question you need to get the array sorted in the manner we humans would have done it i.e picture1 then picture2 etc.. Which of the following function should be used?

A. dsort()
B. casesort()
C. natcasesort()
D. naturalsort()
Answer» D. naturalsort()
284.

What will be the output of the following PHP code?

A. Array ( [0] => picture1.JPG [1] => Picture10.jpg [2] => picture2.jpg [3] => picture20.jpg )
B. Array ( [0] => picture1.JPG [1] => picture2.jpg [2] => Picture10.jpg [3] => picture20.jpg )
C. Array ( [0] => Picture10.jpg [1] => picture1.JPG [2] => picture2.jpg [3] => picture20.jpg )
D. Array ( [0] => Picture10.jpg [1] => picture1.JPG [2] => picture20.jpg [3] => picture2.jpg )
Answer» D. Array ( [0] => Picture10.jpg [1] => picture1.JPG [2] => picture20.jpg [3] => picture2.jpg )
285.

What will be the output of the following PHP code?

A. Array ( [1] => apple [0] => mango [2] => peach [3] => pear )
B. Array ( [0] => apple [1] => mango [2] => peach [3] => pear )
C. Error
D. Array ( [1] => apple [0] => mango [3] => peach [2] => pear )
Answer» B. Array ( [0] => apple [1] => mango [2] => peach [3] => pear )
286.

Which of the functions is used to sort an array in descending order?

A. sort()
B. asort()
C. rsort()
D. dsort()
Answer» D. dsort()
287.

What will be the output of the following PHP code?

A. mango
B. Error
C. peach
D. 0
Answer» C. peach
288.

What will be the output of the following PHP code?

A. green
B. red
C. blue
D. none of the mentioned
Answer» C. blue
289.

What will be the output of the following PHP code?

A. Array ( [0] => red [1] => green )
B. Array ( [0] => green [1] => blue )
C. Array ( [0] => red [1] => blue )
D. Array ( [0] => red [1] => blue )
Answer» B. Array ( [0] => green [1] => blue )
290.

What will be the output of the following PHP code?

A. Array ( [0] => red [1] => green)
B. Array ( [0] => blue [1] => yellow [2] => red [3] => green )
C. Array ( [0] => red [1] => green [2] => blue [3] => yellow )
D. Array ( [0] => blue [1] => yellow )
Answer» D. Array ( [0] => blue [1] => yellow )
291.

What will be the output of the following PHP code?

A. Array ( [3] => blue [4] => blue) Array ( [0] => red )
B. Array ( [4] => blue [5] => blue [6] => blue) Array ( [0] => red )
C. Array ( [3] => blue [4] => blue [5] => blue [6] => blue ) Array ()
D. Array ( [3] => blue [4] => blue [5] => blue [6] => blue ) Array ( [0] => red )
Answer» E.
292.

What will be the output of the following PHP code?

A. Array ( [d] => yellow )
B. Array ( [c] => blue )
C. Array ( [a] => red )
D. Array ( [e] => yellow )
Answer» B. Array ( [c] => blue )
293.

What will be the output of the following PHP code?

A. Array ( [A] => 2 [Cat] => 1 [Dog] => 2 )
B. Array ( [A] => 2 [Cat] => 2 [Dog] => 1 )
C. Array ( [A] => 1 [Cat] => 1 [Dog] => 2 )
D. Array ( [A] => 1 [Cat] => 1 [Dog] => 2 )
Answer» B. Array ( [A] => 2 [Cat] => 2 [Dog] => 1 )
294.

What will be the output of the following PHP code?

A. Array ( Peter Ben Joe )
B. Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 )
C. Array ( 35 37 43 )
D. Array ( “[Peter] => 35” “[Ben] => 37” “[Joe] => 43” )
Answer» C. Array ( 35 37 43 )
295.

What will be the output of the following PHP code?

A. Array ( [0] => Array ( [1] => Volvo [2] => BMW ) [1] => Array ( [1] => Toyota [2] => Honda ) [2] => Array ( [1] => Mercedes [2] => Opel ) )
B. Array ( [1] => Array ( [1] => Volvo [2] => BMW ) [2] => Array ( [1] => Toyota [2] => Honda ) [3] => Array ( [1] => Mercedes [2] => Opel ) )
C. Array ( [0] => Array ( [0] => Volvo [1] => Volvo ) [1] => Array ( [0] => BMW [1] => BMW ) [2] => Array ( [0] => Toyota [1] => Toyota ) )
D. Array ( [0] => Array ( [0] => Volvo [1] => BMW ) [1] => Array ( [0] => Toyota [1] => Honda ) [2] => Array ( [0] => Mercedes [1] => Opel ) )
Answer» E.
296.

What will be the output of the following PHP code?

A. Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 )
B. Array ( [peter] => 35 [ben] => 37 [joe] => 43 )
C. Array ( [PETER] => 35 [BEN] => 37 [JOE] => 43 )
D. Array ( [PeTeR] => 35 [BeN] => 37 [Joe] => 43 )
Answer» D. Array ( [PeTeR] => 35 [BeN] => 37 [Joe] => 43 )
297.

What will be the output of the following PHP code?

A. I like Volvo BMW and Toyota)
B. I like Volvo, BMW and Toyota)
C. I like Volvo, BMW and Toyota
D. I like. Volvo.,. BMW. and) Toyota)
Answer» C. I like Volvo, BMW and Toyota
298.

What will be the output of the following PHP code ?

A. Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 )
B. Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 )
C. Array ( [0] => 5 [1] => 5 [2] => 5 [3] => 5 [4] => 5 [5] => 5 )
D. Array ( [0] => 0 [5] => 5 )
Answer» B. Array ( [0] => 0 [1] => 0 [2] => 0 [3] => 0 [4] => 0 [5] => 0 )
299.

What will be the output of the following PHP code ?

A. Lucy
B. peter
C. Susan
D. Edmund
Answer» C. Susan
300.

What will be the output of the following PHP code ?

A. a
B. b
C. c
D. d
Answer» D. d