Object Oriented Concept — Part 2 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Object Oriented Concept — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/40 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
PHP recognizes constructors by the name_________
Correct Answer: Option D — function __construct()
Detailed Academic Explanation:
A double underscore followed by the construct keyword. Its syntax is function __construct ([ argument1, argument2,…..]) { Class Initialization code }.
💡Key Conceptual Anchor:Object Oriented Concept
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which version of PHP introduced the instanceof keyword?
Correct Answer: Option B — PHP 5
Detailed Academic Explanation:
Using instanceof keyword we can determine whether an object is an instance of a class. $manager = new Employee() … if ($manager instanceof Employee) echo “True”;
💡Key Conceptual Anchor:Object Oriented Concept
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following functions is used to determine whether a class exists?
Correct Answer: Option C — class_exist()
Detailed Academic Explanation:
The class_exist() function returns true or false according to whether the class exists within the currently executing script content.
💡Key Conceptual Anchor:Object Oriented Concept
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following functions is used to determine object type?
Correct Answer: Option C — is_a()
Detailed Academic Explanation:
The is_a() function returns true if object belongs to a class type or if it belongs to a class that is a child of that class. Or else false is returned.
💡Key Conceptual Anchor:Object Oriented Concept
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In the PHP code given below, what is/are the properties? <?php class Example { public $name; function Sample () { echo "This is an example" ; } } ?>
Correct Answer: Option B — public $name
Detailed Academic Explanation:
Yes they are nothing but variables.
💡Key Conceptual Anchor:Object Oriented Concept
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following advanced OOP features is/are not supported by PHP? 1. Method overloading 2. Multiple Inheritance 3. Namespaces 4. Object Cloning
Correct Answer: Option C — 1 and 2
Detailed Academic Explanation:
The advanced OOP features are: Object cloning, Inheritance, Interfaces, Abstract classes, and Namespaces.
💡Key Conceptual Anchor:Object Oriented Concept
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following is the right way to clone an object?
Correct Answer: Option B — destinationObject = clone targetObject
Detailed Academic Explanation:
You can clone an object by prefacing it with the clone keyword.
💡Key Conceptual Anchor:Object Oriented Concept
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which feature allows us to call more than one method or function of the class in single instruction?
Correct Answer: Option D — Method chaining
Detailed Academic Explanation:
Following is a basic example of method chaining in php: $a = new Order(); $a->CreateOrder()->sendOrderEmail()->createShipment();
💡Key Conceptual Anchor:Object Oriented Concept
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
A package is a set of related _________
Correct Answer: Option B — Classes
Detailed Academic Explanation:
A package is a set of related classes, usually grouped together in some way. Packages can be used to separate parts of a system from one another.
💡Key Conceptual Anchor:Object Oriented Concept
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Till which version of PHP, developers were forced to name their files in a global context?
Correct Answer: Option D — PHP 5.3
Detailed Academic Explanation:
If you named a class ShoppingBasket, it would become instantly available across your system.
💡Key Conceptual Anchor:Object Oriented Concept
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following can you place inside a namespace? 1. classes 2. functions 3. variables
Correct Answer: Option D — All of the mentioned
Detailed Academic Explanation:
A namespace is a bucket in which you can place your classes, functions and variables.
💡Key Conceptual Anchor:Object Oriented Concept
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following is the correct way of declaring a namespace?
Correct Answer: Option A — namespace my
Detailed Academic Explanation:
The namespace declaration must be the first statement in its file.
💡Key Conceptual Anchor:Object Oriented Concept
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which symbol is used to declare nested namespaces?
Correct Answer: Option B — \
Detailed Academic Explanation:
Example – namespace com\getinstance\util;
💡Key Conceptual Anchor:Object Oriented Concept
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which keyword can be used to fix the above error?
Correct Answer: Option C — use
Detailed Academic Explanation:
Use keyword allows you to alias other namespaces within the current namespace. Example – namespace main; use comgetinstanceutil; utilDebug::helloWorld();
💡Key Conceptual Anchor:Object Oriented Concept
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following statements is true for include_once() and require_once()?
Correct Answer: Option D — Both do not handle the errors in the same way
Detailed Academic Explanation:
The only difference between the include() and require() statements lies in their handling of errors. A file invoked using require() will bring down your entire process when you meet an error. The same error encountered via a call to include() will merely generate a warning and end execution of the included file.
💡Key Conceptual Anchor:Object Oriented Concept
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following statements is true for require() and require_once()?
Correct Answer: Option B — They are statements
Detailed Academic Explanation:
require() and require_once() are actually statements, not functions. This means that you can omit the brackets when using them.
💡Key Conceptual Anchor:Object Oriented Concept
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which function was introduced to help automate the inclusion of class files?
Correct Answer: Option C — __autoload()
Detailed Academic Explanation:
When the PHP engine encounters an attempt to instantiate an unknown class, it invokes the __autoload() function, passing it the class name as a string. It is up to the implementer to define a strategy for locating and including the missing class file.
💡Key Conceptual Anchor:Object Oriented Concept
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How many times can you define _______ autoload in a process?
Correct Answer: Option A — once
Detailed Academic Explanation:
__autoload is a powerful tool, but it does have some limitations. In particular, you can only define it once in a process. If you need to change your autoload function dynamically you should look at the spl_autoload_register function, which supports that functionality.
💡Key Conceptual Anchor:Object Oriented Concept
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following functions will you use to check that the class exists before you work with it?
Correct Answer: Option B — class_exists()
Detailed Academic Explanation:
The class_exists() function accepts a string representing the class to check for and returns a Boolean true value if the class exists and false otherwise.
💡Key Conceptual Anchor:Object Oriented Concept
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following will you use to check the class of an object?
Correct Answer: Option D — get_class()
Detailed Academic Explanation:
This function accepts any object as an argument and returns its class name as a string.
💡Key Conceptual Anchor:Object Oriented Concept
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
PHP 4 did not support instanceof. Instead, which function did it provide?
Correct Answer: Option C — is_a()
Detailed Academic Explanation:
As of PHP 5.3 is_a() no longer deprecated.
💡Key Conceptual Anchor:Object Oriented Concept
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
You use the get_class_methods() function to return the names of all the methods in the class. Which function will you use to print it on the screen?
Correct Answer: Option C — print_r
Detailed Academic Explanation:
The function get_class_methods returns an array therefore we cannot use echo.
💡Key Conceptual Anchor:Object Oriented Concept
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
If you call a method and it doesn’t exist it’ll cause a problem. To check the method which function will you use?
Correct Answer: Option C — is_callable()
Detailed Academic Explanation:
There is another method which you can use – method_exists() for similar purpose.
💡Key Conceptual Anchor:Object Oriented Concept
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output if a protected method is given as argument to the function method_exist()?
Correct Answer: Option D — True
Detailed Academic Explanation:
method_exists() returns true for private and protected methods as well as for public ones. Remember that the fact that a method exists does not mean that it will be callable.
💡Key Conceptual Anchor:Object Oriented Concept
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following function should I use to find the parent class of a class?
Correct Answer: Option A — get_parent_class()
Detailed Academic Explanation:
The class functions also allow us to chart inheritance relationships.This function requires either an object or a class name, and it returns the name of the superclass, if any. If no such class exists, that is, if the class we are testing does not have a parent, then the function returns false.
💡Key Conceptual Anchor:Object Oriented Concept
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which class accepts a class name or an object reference and returns an array of interface name?
Correct Answer: Option A — class_implements()
Detailed Academic Explanation:
is_subclass_of() will tell you only about class inheritance relationships. It will not tell you that a class implements an interface.
💡Key Conceptual Anchor:Object Oriented Concept
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Object-oriented code tries to minimize dependencies by moving responsibility for handling tasks away from _______ and toward the objects in the system.
Correct Answer: Option B — client code
Detailed Academic Explanation:
Procedural code takes the form of a sequential series of commands and method calls. The controlling code tends to take responsibility for handling differing conditions. This top-down control can result in the development of duplications and dependencies across a project. Object-oriented code tries to minimize these dependencies by moving responsibility for handling tasks away from client code and toward the objects in the system.
💡Key Conceptual Anchor:Object Oriented Concept
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Placing a static method for generating _______ objects in the ________ class is convenient.
Correct Answer: Option A — child parent
Detailed Academic Explanation:
Such a design decision does have its own consequences, however.
💡Key Conceptual Anchor:Object Oriented Concept
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The extent to which proximate procedures are related to one another is known as.
Correct Answer: Option C — Cohesion
Detailed Academic Explanation:
Ideally, you should create components that share a clear responsibility. If your code spreads related routines widely, you will find them harder to maintain as you have to hunt around to make changes. Our ParamHandler classes collect related procedures into a common context.
💡Key Conceptual Anchor:Object Oriented Concept
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
______ occurs when discrete parts of a system’s code are tightly bound up with one another so that a change in one part necessitates changes in the others.
Correct Answer: Option B — Tight Coupling
Detailed Academic Explanation:
Tight coupling is by no means unique to procedural code, though the sequential nature of such code makes it prone to the problem.
💡Key Conceptual Anchor:Object Oriented Concept
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
________ code makes change easier because the impact of altering an implementation will be localized to the component being altered.
Correct Answer: Option A — Orthogonal
Detailed Academic Explanation:
Orthogonality, it is argued, promotes reuse in that components can be plugged into new systems without needing any special configuration. Such components will have clear inputs and outputs independent of any wider context.
💡Key Conceptual Anchor:Object Oriented Concept
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Polymorphism is also known as______
Correct Answer: Option D — class switching
Detailed Academic Explanation:
Polymorphism is the maintenance of multiple implementations behind a common interface.
💡Key Conceptual Anchor:Object Oriented Concept
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following is know as the key to object-oriented programming?
Correct Answer: Option B — Encapsulation
Detailed Academic Explanation:
Encapsulation simply means the hiding of data and functionality from a client.
💡Key Conceptual Anchor:Object Oriented Concept
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one among the following means tight coupling?
Correct Answer: Option A — Code Duplication
Detailed Academic Explanation:
Duplication is one of the great evils in code. Take a look at the instances of repetition in your system. Perhaps they belong together. If you change something fundamental about one routine, will the similar routines need amendment? If this is the case, they probably belong in the same class.
💡Key Conceptual Anchor:Object Oriented Concept
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
UML stands for?
Correct Answer: Option D — unified modeling language
Detailed Academic Explanation:
The UML emerged as a standard only after long years of intellectual and bureaucratic sparring among the great and good of the object oriented design community.
💡Key Conceptual Anchor:Object Oriented Concept
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In a class diagram the class is divided into three sections, what is displayed in the first section?
Correct Answer: Option C — Class Name
Detailed Academic Explanation:
The other two sections are optional when no more information than the class name is known.
💡Key Conceptual Anchor:Object Oriented Concept
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
_________ are used in class diagrams to describe the way in which specific elements should be used.
Correct Answer: Option B — Constraints
Detailed Academic Explanation:
The {abstract} syntax is an example of a constraint. There is no special structure for the text between the braces; it should simply provide a short clarification of any conditions that may apply to the element.
💡Key Conceptual Anchor:Object Oriented Concept
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which one of the following is displayed below the class name in the class diagrams?
Correct Answer: Option C — Attributes
Detailed Academic Explanation:
Attributes describe a class’s properties. Attributes are listed in the section directly beneath the class name.
💡Key Conceptual Anchor:Object Oriented Concept
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
+ is the visibility code for?
Correct Answer: Option A — Public
Detailed Academic Explanation:
The visibility symbol is followed by the name of the attribute.
💡Key Conceptual Anchor:Object Oriented Concept
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which relationship is illustrated by a line that begins with an unfilled diamond?
Correct Answer: Option C — Aggregation
Detailed Academic Explanation:
In the case of aggregation, the contained objects are a core part of the container, but they can also be contained by other objects at the same time.
💡Key Conceptual Anchor:Object Oriented Concept
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.