MCQ Practice Single Best Answer Topic: Object Oriented Concept of PHP

Q 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 }

Question ID
#2577
Subchapter
Object Oriented Concept of PHP
Action
Choose one option below

Choose Your Answer

Click an option to check whether your answer is correct.

  • A Only (ii)
  • B Only (iv)
  • C (i) and (ii)
  • D (iii) and (iv)
Correct 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.

Share This Question

Share this MCQ with your friends or study group.