ExamVeda
Login
Home
11
Inheritance is the means by which one or more classes can be derived from a/an ___ class.
Discuss
Answer & Solution
Answer: Option A
Solution:
A class that inherits from another is said to be a subclass of it. This relationship is often described in terms of parents and children. A child class is derived from and inherits characteristics from the parent.
12
What will be the output of the following PHP code?
<?php
class MyClass
{
}
 
$a = new MyClass;
var_dump(!($a instanceof stdClass));
?>
Discuss
Answer & Solution
Answer: Option A
Solution:
To check if an object is not an instanceof a class, the logical not operator can be used.
13
What should be used to refer to a method in the context of a class rather than an object you use?
Discuss
Answer & Solution
Answer: Option D
Solution:
Example- parent::__construct()
14
Prior to which version of PHP did constructors took the name of the enclosing class.
Discuss
Answer & Solution
Answer: Option B
Solution:
The new unified constructors use the name __construct(). Using the old syntax, a call to a parent constructor would tie you to that particular class: parent::ShopProduct();
15
Which method or property can only be accessed from within the enclosing class? Even subclasses have no access.
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board
16
A mutator method is also called as.
Discuss
Answer & Solution
Answer: Option A
Solution:
An accessor method is called getter. The common use of a mutator method is to initialise the value of member variables of a class.
17
Which version of PHP introduced the static keyword?
Discuss
Answer & Solution
Answer: Option B
Solution:
The static keyword was introduced with PHP 5. It cannot be used in PHP 4 scripts.
18
Which keyword is used to access a static method or property from within the same class(rather than from child)?
Discuss
Answer & Solution
Answer: Option C
Solution:
Self is to classes what the $this pseudo-variable is to objects.
19
In which of the following circumstance should you use a static reference to a non static method?
Discuss
Answer & Solution
Answer: Option A
Solution:
Making a method call using parent is the only circumstance in which you should use a static reference to a non-static method.
20
Which one of the following variable cannot be used inside a static method?
Discuss
Answer & Solution
Answer: Option A
Solution:
By definition, static methods are not invoked in the context of an object. For this reason, static methods and properties are often referred to as class variables and properties.