ExamVeda
Login
Home
1
Which one of the following is not a valid class name?
Discuss
Answer & Solution
Answer: Option D
Solution:
You declare a class with the class keyword and an arbitrary class name. Class names can be any combination of numbers and letters, although they must not begin with a number.
2
Fill in the blank with the best option. An Object is a/an ________ of a class.
Discuss
Answer & Solution
Answer: Option C
Solution:
An object is said to be an instance of its class. It is of the type defined by the class.
3
Which version of PHP introduced the visibility keywords i.e public, private, and protected?
Discuss
Answer & Solution
Answer: Option B
Solution:
In PHP 4, all properties were declared with var keyword, which is identical in effect to using public. For the sake of backward compatibility, PHP 5 accepts var in place of public for properties.
4
Which characters is used to access property variables on an object-by-object basis?
Discuss
Answer & Solution
Answer: Option C
Solution:
Example: $product1->title=”My Life”;
5
Code that uses a class, function, or method is often described as the.
Discuss
Answer & Solution
Answer: Option A
Solution:
Code that uses a class, function, or method is often described as the class’s, function’s, or method’s client or as client code.
6
Which keyword precedes a method name?
Discuss
Answer & Solution
Answer: Option B
Solution:
A method declaration resembles a function declaration. The function keyword precedes a method name, followed by an optional list of argument variables in parentheses.
7
If you omit the visibility keyword in your method declaration, by default the method will be declared as.
Discuss
Answer & Solution
Answer: Option A
Solution:
By declaring a method public, you ensure that it can be invoked from outside of the current object.
8
Which function is used to determine whether the variable’s value is either TRUE or FALSE?
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
9
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 );
?>
Discuss
Answer & Solution
Answer: Option D
No explanation is given for this question. Let's Discuss on Board
10
Which version of PHP introduced class type hints?
Discuss
Answer & Solution
Answer: Option C
No explanation is given for this question. Let's Discuss on Board