Menu
H
HomeA
AptitudeE
EnglishR
ReasoningD
DIG
GKC
Current AffairsI
Interview- Computer
C
Computer FundamentalsN
NetworkingS
SQLD
Database
- Programming
C
C ProgramJ
Java ProgramH
HTMLC
J
JavascriptP
PHP Program
- Engineering
C
Computer ScienceE
Electrical EngineeringM
Mechanical EngineeringC
Civil EngineeringC
Chemical Engineering
- More
B
Banking AwarenessC
CommerceM
Management
A
Ask Question
- Home
- Aptitude
- English
- Reasoning
- DI
- GK
- Current Affairs
- Interview
- Computer
- Computer Fundamentals
- Networking
- SQL
- Database
- Programming
- C Program
- Java Program
- HTML
- CSS
- Javascript
- PHP Program
- Engineering
- Computer Science
- Electrical Engineering
- Mechanical Engineering
- Civil Engineering
- Chemical Engineering
- More
- Banking Awareness
- Commerce
- Management
- Ask Question
Join The Discussion
Related Questions on Object Oriented Concept
This set of PHP Multiple Choice Questions & Answers [MCQs] focuses on “Basics of Object-Oriented PHP”. 1. The practice of separating the user from the true inner workings of an application through well-known interfaces is known as _________ Answer: c 2. 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? Answer: b 3. The practice of creating objects based on predefined classes is often referred to as ______________ Answer: d 4. Which one of the following property scopes is not
supported by PHP? Answer: a 5. Which one of the following can be used to instantiate an object in PHP assuming class name to be Foo? Answer: c 6. Which one of the following is the right way to define a constant? Answer: d 7. Which one of the following is the right way to call a class constant, given that the class is mathFunction? Answer: c 8. Which one of the following is the right way to invoke a method?
a] Polymorphism
b] Inheritance
c] Encapsulation
d] Abstraction
View Answer
Explanation: In object-oriented PHP encapsulation is a concept of wrapping up or binding up the data members and methods in a single module.
a] Abstraction
b] Polymorphism
c] Inheritance
d] Differential
View Answer
Explanation: The word polymorphism is derived from Greek word poly which means “many” and morphism which means the property which helps us to assign more than one property.
a] class creation
b] object creation
c] object instantiation
d] class instantiation
View Answer
Explanation: In object-oriented programming, classes are the blueprints of php objects. Classes do not actually become objects until instantiation is done. When someone instantiates a class, it creates an instance of it, thus creating the object. In other words, instantiation is the process of creating an instance of an object in memory.
a] friendly
b] final
c] public
d] static
View Answer
Explanation: PHP supports five class property scopes: public, private, protected, final and static.
a] $obj = new $foo;
b] $obj = new foo;
c] $obj = new foo [];
d] obj = new foo [];
View Answer
Explanation: To create a new object in PHP we can use the new statement to instantiate a class.
a] constant PI = “3.1415”;
b] const $PI = “3.1415”;
c] constant PI = ‘3.1415’;
d] const PI = ‘3.1415’;
View Answer
Explanation:
Class constants are created like: const NAME = ‘VALUE’;
a] echo PI;
b] echo mathFunction->PI;
c] echo mathFunction::PI;
d] echo mathFunction=PI;
View Answer
Explanation: The Scope Resolution Operator “::” is a token that allows access to static, constant, and overridden
properties or methods of a class.
a] $object->methodName[];
b] object->methodName[];
c] object::methodName[];
d] $object::methodName[];
View Answer
Answer: a
Explanation: “->” is a dynamic class method invocation in PHP.
9. Which of the following is/are the right way to declare a method?
i] function functionName[] { function body } ii] scope function functionName[] { function body } iii] method methodName[] { method body } iv] scope method methodName[] { method body }
a]
Only ii]
b] Only iv]
c] i] and ii]
d] iii] and iv]
View Answer
Answer: c
Explanation: In case of public methods, you can forgo explicitly declaring the scope and just declare the method like you would a function.
10. Which of the following method scopes is/are not supported by PHP?
i] private ii] friendly iii] static iv] abstract
a] Only ii]
b] Only iv]
c] ii] and iv]
d] Only i]
View Answer
Answer: a
Explanation: PHP supports six method scopes: public, private, final, static, protected and abstract. But it does not support friendly.
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.
Next Steps:
- Get Free Certificate of Merit in PHP Programming
- Participate in PHP Programming Certification Contest
- Become a Top Ranker in PHP Programming
- Take PHP Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
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 & technical discussions at Telegram SanfoundryClasses.