How to implement a class named Dragonball. This class must have an attribute named ballCount (which starts from 0) and a method iFoundaBall. When iFoundaBall is called, ballCount is increased by one. If the value of ballCount is equal to seven, then the message You can ask your wish is printed, and ballCount is reset to 0. How would you implement this class?
Submitted by: Muhammad<?php
class dragonBall{
private $ballCount;
public function __construct(){
$this->ballCount=0;
}
public function iFoundaBall(){
$this->ballCount++;
if($this->ballCount===7){
echo "You can ask for your wish.";
$this->ballCount=0;
}
}
}
?>
This question will evaluate a candidate’s knowledge about OOP.
Submitted by: Muhammad
class dragonBall{
private $ballCount;
public function __construct(){
$this->ballCount=0;
}
public function iFoundaBall(){
$this->ballCount++;
if($this->ballCount===7){
echo "You can ask for your wish.";
$this->ballCount=0;
}
}
}
?>
This question will evaluate a candidate’s knowledge about OOP.
Submitted by: Muhammad
Read Online PHP Community Marketing Expert Job Interview Questions And Answers
Top PHP Community Marketing Expert Questions
☺ | Tell me what does the following code output? |
☺ | Tell me how would you declare a function that receives one parameter name hello? |
☺ | Tell me what is the output of the following code: |
☺ | Explain do you use Composer? If yes, what benefits have you found in it? |
Top Social Networking And Marketing Categories
☺ | SMM Interview Questions. |
☺ | Social Media Interview Questions. |
☺ | Online Media Operator Interview Questions. |
☺ | PHP Community Marketing Expert Interview Questions. |
☺ | Social Media Executive Interview Questions. |