Vidyalelo
PHP · all questions

Object Oriented Concept
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

141

Questions

1/8

Page

Pick an option on a question to see the right answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

Which keyword precedes a method name?

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
class ShopProductWriter
{
    public function write($shopProduct)
    {
      str = "<span class="p-red">{shopProduct->title}: " .shopProduct<span class="p-blue">-></span>getProducer<span class="p-blue">()</span> ." <span class="p-red">({shopProduct->price})n";
      print $str;
    }
}
$product1 = new ShopProduct( "My Antonia", "Willa", "Cather", 5.99 );
$writer = new ShopProductWriter();
product1 );
?>

Select an option to see the answer and solution.

Which version of PHP introduced class type hints?

Select an option to see the answer and solution.

Inheritance is the means by which one or more classes can be derived from a/an ___ class.

Select an option to see the answer and solution.

What will be the output of the following PHP code?
<?php
class MyClass
{
}
 
$a = new MyClass;
var_dump(!($a instanceof stdClass));
?>

Select an option to see the answer and solution.

What should be used to refer to a method in the context of a class rather than an object you use?

Select an option to see the answer and solution.

Prior to which version of PHP did constructors took the name of the enclosing class.

Select an option to see the answer and solution.

Which method or property can only be accessed from within the enclosing class? Even subclasses have no access.

Select an option to see the answer and solution.

A mutator method is also called as.

Select an option to see the answer and solution.

Which version of PHP introduced the static keyword?

Select an option to see the answer and solution.

Which keyword is used to access a static method or property from within the same class(rather than from child)?

Select an option to see the answer and solution.

In which of the following circumstance should you use a static reference to a non static method?

Select an option to see the answer and solution.

Which one of the following variable cannot be used inside a static method?

Select an option to see the answer and solution.