My Report

PHP Object Test – 1


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. Which function is used to determine whether the variable's value is either TRUE or FALSE?

2. Which version of PHP introduced the visibility keywords i.e public, private, and protected?

3. Which keyword precedes a method name?

4. What will be the output of the following PHP code?

<?php
    class ShopProductWriter
    {
        public function write( $shopProduct )
        {
            $str = "{$shopProduct->title}: " .$shopProduct->getProducer() ." ({$shopProduct->price})\n";
            print $str;
        }
    }
    $product1 = new ShopProduct( "My Antonia", "Willa", "Cather", 5.99 );
    $writer = new ShopProductWriter();
    $writer->write( $product1 );
?>

5. Which characters is used to access property variables on an object-by-object basis?

6. There are two objects-
$product1 = new Shop();
$product2 = new Shop();
Which one of the following statements is right about them?

7. If you omit the visibility keyword in your method declaration, by default the method will be declared as ____________

8. Which one of the following is not a valid class name?

9. Code that uses a class, function, or method is often described as the ____________

10. Fill in the blank with the best option. An Object is a/an ________ of a class.


 

Start practicing “1000 MCQs on PHP”, and once you are ready, you can take tests on all topics by attempting our “PHP Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
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 & discussions at Telegram SanfoundryClasses.