Q
In PHP, what is the default visibility of class members?

Answer & Solution

Answer: Option A
Solution:
By default, in PHP, class members (properties and methods) are public if no visibility keyword is explicitly specified.
Related Questions on Average

Which of the following is NOT a principle of OOP?

A). Inheritance

B). Polymorphism

C). Abstraction

D). Linearity

What does the protected access modifier mean in PHP?

A). Access to all

B). Access to parent class

C). Access to subclass

D). Restricted access

What is the purpose of method overloading in PHP?

A). Different parameters

B). Same parameters

C). Override a method

D). Access private methods

What is the main purpose of encapsulation?

A). To make classes more readable

B). To hide implementation details

C). To increase code complexity

D). To prevent inheritance

What is the benefit of using polymorphism in PHP?

A). Increased complexity

B). Improved readability

C). Decreased flexibility

D). Increased maintainability

Which keyword is used to access static properties or methods in PHP?

A). this

B). parent

C). self

D). static

Which access modifier in PHP restricts access to class members?

A). public

B). protected

C). private

D). access

How is polymorphism achieved in PHP?

A). Method overriding

B). Method overloading

C). Method inheritance

D). Method encapsulation

In PHP, what is the purpose of the final keyword?

A). To mark a method as deprecated

B). To prevent a class from being inherited

C). To specify a constant value

D). To define a global variable

What does the final keyword do when applied to a method in PHP?

A). Mark as deprecated

B). Prevent override

C). Define as abstract

D). Enable instantiation