Q:
PHP find output programs (Class & Objects) | set 1
belongs to collection: PHP Find Output Programs
PHP Find Output Programs
- PHP find output programs (basics) | set 1
- PHP find output programs (basics) | set 2
- PHP find output programs (basics) | set 3
- PHP find output programs (Superglobals) | set 1
- PHP find output programs (conditional statements) | set 1
- PHP find output programs (conditional statements) | set 2
- PHP find output programs (conditional statements) | set 3
- PHP find output programs (switch Statement) | set 1
- PHP find output programs (switch Statement) | set 2
- PHP find output programs (switch Statement) | set 3
- PHP find output programs (Operators) | set 1
- PHP find output programs (Operators) | set 2
- PHP find output programs (Operators) | set 3
- PHP find output programs (Loops) | set 1
- PHP find output programs (Loops) | set 2
- PHP find output programs (Loops) | set 3
- PHP find output programs (Loops) | set 4
- PHP find output programs (Arrays) | set 1
- PHP find output programs (Arrays) | set 2
- PHP find output programs (Arrays) | set 3
- PHP find output programs (User-defined functions) | set 1
- PHP find output programs (User-defined functions) | set 2
- PHP find output programs (User-defined functions) | set 3
- PHP find output programs (String Functions) | set 1
- PHP find output programs (String Functions) | set 2
- PHP find output programs (Number Functions) | set 1
- PHP find output programs (Math Functions) | set 1
- PHP find output programs (Math Functions) | set 2
- PHP find output programs (Date and Time) | set 1
- PHP find output programs (define Constant) | set 1
- PHP find output programs (static variables, classes, methods) | set 1
- PHP find output programs (static variables, classes, methods) | set 2
- PHP find output programs (Regular Expressions) | set 1
- PHP find output programs (Exceptions) | set 1
- PHP find output programs (Exceptions) | set 2
- PHP find output programs (Filters) | set 1
- PHP find output programs (Filters) | set 2
- PHP find output programs (JSON) | set 1
- PHP find output programs (const Keyword) | set 1
- PHP find output programs (Class & Objects) | set 1
- PHP find output programs (Class & Objects) | set 2
- PHP find output programs (Class & Objects) | set 3
- PHP find output programs (Constructors and Destructors) | set 1
- PHP find output programs (Constructors and Destructors) | set 2
- PHP find output programs (Constructors and Destructors) | set 3
- PHP find output programs (Inheritance) | set 1
- PHP find output programs (Inheritance) | set 2
- PHP find output programs (Inheritance) | set 3
Answer 1:
Output:
Explanation:
In the above program, we created a class that contains three data members $id, $name, and $fee, we also created to methods set and display(). The set() method is used to set values into the data members, and display() method is used to display values of data members.
Then we created two objects $obj1 and $obj2, and we set and display values of both objects.
Answer 2:
Output:
Explanation:
In the above program, we created a class that contains three data members $id, $name, and $fee, we also created to methods set and print(). The set() method is used to set values into the data members, and the print() method is used to display values of data members.
Then we created two objects $obj1 and $obj2, and we set and print values of both objects.
Note: As we know that print() is a built-in function, but here we defined a method with name print. But the scope of both is different, so it will not create any problem.
Answer 3:
Output:
Explanation:
In the above program, we created a class that contains three data members $id, $name, and $fee, we also created to methods set and print().
The set() method is used to set values into the data members, but we did not use $this with data members of class inside the set() method, then values will not set.
The print() method is used to display the values of data members.
Then we created two objects $obj1 and $obj2, and we set and print values of both objects. We here empty values will print on the web page because we did not use $this with data members in the set() method.
Answer 4:
Output:
Explanation:
The above program will generate syntax error, because we did not declare objects in proper way. The way of object declaration is given below:
$obj1 = new Student(); $obj2 = new Student();
Answer 5:
Output:
Explanation:
In the above program, we created a class Sample that contains data member $val. Here, we also created two methods set() and ADD().
The set() method is used to set the value of data member $val, and the ADD() method is used to add the value of the specified object with the value of the current object and return the addition of both.
need an explanation for this answer? contact us directly to get an explanation for this answer