Explore topic-wise MCQs in Php.

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

151.

What does PDO stand for?$?

A. PHP Data Orientation
B. PHP Database Object
C. PHP Database Orientation
D. PHP Data Object
Answer» E.
152.

How many of the following can be contained in constants?1. boolean2. integer3. float4. string$?

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

Which one of the following keyword is used to implement an interface?$?

A. interface
B. get
C. inherit
D. implements
Answer» E.
154.

PHP provides built-in interceptor methods, which can intercept messages sent to undefined methods and properties. This is also known as _________$?

A. overloading
B. overriding
C. overbending
D. overbinding
Answer» B. overriding
155.

Which keyword must be added before $first variable on the third line of the above question to make $second and $first as distinct objects in PHP 5?$?

A. copy
B. clone
C. cut
D. Can’t add any word to make them distinct
Answer» C. cut
156.

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

A. Abstract
B. Protected
C. Final
D. Static
Answer» D. Static
157.

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

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

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
159.

Which of the following advanced OOP features is/are not supported by PHP?1. Method overloading2. Multiple Inheritance3. Namespaces4. Object Cloning$?

A. All of the mentioned
B. None of the mentioned
C. 1 and 2
D. 3 and 4
Answer» D. 3 and 4
160.

Which one of the following functions is used to determine object type?$?

A. obj_type()
B. type()
C. is_a()
D. is_obj()
Answer» D. is_obj()
161.

What is the value of message?$name = “John”;$message = ‘Hello, $name’;?

A. Hello, John
B. it will print an error message
C. ‘Hello, $name’
D. none of above
Answer» D. none of above
162.

Which keyword must be added before $first variable on the third line of the above question to make $second and $first as distinct objects in PHP 5??

A. copy
B. clone
C. cut
D. Can’t add any word to make them distinct
Answer» C. cut
163.

Which one of the following keyword is used to implement an interface??

A. interface
B. get
C. inherit
D. implements
Answer» E.
164.

PHP provides built-in interceptor methods, which can intercept messages sent to undefined methods and properties. This is also known as _________?

A. overloading
B. overriding
C. overbending
D. overbinding
Answer» B. overriding
165.

Which keyword precedes a method name??

A. method
B. function
C. public
D. protected
Answer» C. public
166.

What does PDO stand for??

A. PHP Data Orientation
B. PHP Database Object
C. PHP Database Orientation
D. PHP Data Object
Answer» E.
167.

How many of the following can be contained in constants?1. boolean2. integer3. float4. string?

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

Inheritance is the means by which one or more classes can be derived from a/an ___ class.?

A. base
B. abstract
C. null
D. predefined
Answer» B. abstract
169.

A mutator method is also called as.?

A. Setter
B. Accessor
C. Getter
D. Destructor
Answer» B. Accessor
170.

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
171.

Which of the following advanced OOP features is/are not supported by PHP?1. Method overloading2. Multiple Inheritance3. Namespaces4. Object Cloning?

A. All of the mentioned
B. None of the mentioned
C. 1 and 2
D. 3 and 4
Answer» D. 3 and 4
172.

Which one of the following functions is used to determine object type??

A. obj_type()
B. type()
C. is_a()
D. is_obj()
Answer» D. is_obj()
173.

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

A. Abstract
B. Protected
C. Final
D. Static
Answer» D. Static
174.

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

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

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
176.

Which one among the following means tight coupling?

A. Code Duplication
B. Inheritance
C. Encapsulation
D. Polymorphism
Answer» B. Inheritance
177.

The extent to which proximate procedures are related to one another is known as.

A. Coupling
B. Balancing
C. Cohesion
D. Co-relation
Answer» D. Co-relation
178.

Which of the below is most useful for debugging:

A. print()
B. printf()
C. print_r()
D. echo
Answer» D. echo
179.

Which one of the following statements is true ?class CopyMe {}$first = new CopyMe();$second = $first;

A. In PHP 4: $second and $first are 2 distinct objects
B. In PHP 5: $second and $first are 2 distinct objects
C. In PHP 4: $second and $first refer to one object
D. None of the mentioned
Answer» B. In PHP 5: $second and $first are 2 distinct objects
180.

Atleast how many abstract methods must an abstract class contain?

A. None
B. One
C. Two
D. Five
Answer» C. Two
181.

Code that uses a class, function, or method is often described as the.

A. client code
B. user code
C. object code
D. class code
Answer» B. user code
182.

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

A. Only 2
B. All of the mentioned
C. 2 and 4
D. 2, 3 and 4
Answer» B. All of the mentioned
183.

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
184.

Which of the following method scopes is/are not supported by PHP?1. private2. final3. static4 abstract

A. Only 2
B. Only 4
C. 2 and 4
D. None of the mentioned
Answer» E.
185.

What will be the output of the following PHP code?class Checkout { final function totalize() { // calculate bill } } class IllegalCheckout extends Checkout { final function totalize() { // change bill calculation }}

A. PHP Fatal error: Class IllegalCheckout may not inherit from final class
B. Value of the bill calculated
C. PHP Fatal error: Cannot find object
D. PHP Fatal error: Cannot override final method
Answer» E.
186.

If you call a method and it doesn’t exist it’ll cause a problem. To check the method which function will you use?#

A. _method()
B. methodexists()
C. is_callable()
D. is_method()
Answer» D. is_method()
187.

How many times can you define _______ autoload in a process?

A. once
B. twice
C. thrice
D. as many times as needed
Answer» B. twice
188.

Which one of the following is know as the key to object-oriented programming?

A. Polymorphism
B. Encapsulation
C. Data Abstraction
D. Orthogonality
Answer» C. Data Abstraction
189.

Placing a static method for generating _______ objects in the ________ class is convenient.

A. child parent
B. parent child
C. final static
D. static final
Answer» B. parent child
190.

In PHP, the difference between double quote and single quote is that variables . . . . in single quoted strings whereas they . . . . . in double quoted strings.

A. are not parsed, are parsed
B. are parsed, are not parsed
C. are class, are not class
D. are variables, are not variables
Answer» B. are parsed, are not parsed
191.

Child classes are defined using the keyword .....

A. extends
B. extents
C. child_class
D. extend_class
Answer» B. extents
192.

A class may contain its own .............

A. variables
B. functions
C. constants
D. both A and B
E. all of above
Answer» F.
193.

The pseudo-variable ...... is available inside any class method when that method is called from within an object context.

A. $construct
B. #this
C. $those
D. $this
Answer» E.
194.

When you extend a class, the subclass inherits all of the ........ methods from the parent class.

A. Public
B. private
C. protected
D. both A and C
Answer» E.