This set of PHP Multiple Choice Questions & Answers (MCQs) focuses on “Object and Design-1”.
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
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
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…
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
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.
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.
6. Polymorphism is also known as______
d) class switching
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 ?
c) Data Abstraction
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
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
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
Explanation: The other two sections are optional when no more information than the class name is known.
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.