PHP Multiple Choice Questions – Object and Design

This set of PHP Multiple Choice Questions & Answers (MCQs) focuses on “Object and Design”.

1. Object-oriented code tries to minimize dependencies by moving responsibility for handling tasks away from ___ and toward the objects in the system.
a) server code
b) client code
c) machine code
d) procedural code
View Answer

Answer: b
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.

2. Placing a static method for generating ________ objects in the ____________ class is convenient.
a) child parent
b) parent child
c) final static
d) static final
View Answer

Answer: a
Explanation: Such a design decision does have its own consequences, however.

3. The extent to which proximate procedures are related to one another is known as ________
a) Coupling
b) Balancing
c) Cohesion
d) Co-relation
View Answer

Answer: c
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 Param Handler classes collect related procedures into a common context.

4. ______ 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.
a) Loose Coupling
b) Tight Coupling
c) Co-relation
d) Balancing
View Answer

Answer: b
Explanation: Tight coupling is by no means unique to procedural code, though the sequential nature of such code makes it prone to the problem.

5. ________ code makes change easier because the impact of altering an implementation will be localized to the component being altered.
a) Orthogonal
b) Cohesion
c) Coupling
d) Balancing
View Answer

Answer: a
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.
Note: Join free Sanfoundry classes at Telegram or Youtube

6. Polymorphism is also known as______
a) switch
b) overact
c) encapsulation
d) class switching
View Answer

Answer: d
Explanation: Polymorphism is the maintenance of multiple implementations behind a common interface.

7. Which one of the following is known as the key to object-oriented programming?
a) Polymorphism
b) Encapsulation
c) Data Abstraction
d) Orthogonality
View Answer

Answer: b
Explanation: Encapsulation simply means the hiding of data and functionality from a client.

8. Which one among the following means tight coupling?
a) Code Duplication
b) Inheritance
c) Encapsulation
d) Polymorphism
View Answer

Answer: a
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.

9. UML stands for?
a) unified mailing language
b) unified modeling logo
c) undefined modeling language
d) unified modeling language
View Answer

Answer: d
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.

10. In a class diagram the class is divided into three sections, what is displayed in the first section?
a) Class Attributes
b) Class Declaration
c) Class Name
d) Class Functions
View Answer

Answer: c
Explanation: The other two sections are optional when no more information than the class name is known.

More MCQs on PHP Object and Design:

Sanfoundry Global Education & Learning Series – PHP Programming.

To practice all questions on PHP Programming, here is complete set of 1000+ Multiple Choice Questions and Answers on PHP.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.