PHP

PHP

Basics of Object-Oriented has 20 Questions

The practice of separating the user from the true inner workings of an application through well-known interfaces is known as..

Polymorphism
Inheritance
Encapsulation
Abstraction
Which of the following term originates from the Greek language that means "having multiple forms,"? defines OOP's ability to redefine, a class's characteristics?

Abstraction
Polymorphism
Inheritance
Differential
The practice of creating objects based on predefined classes is often referred to as..

class creation
object creation
object instantiation
class instantiation
Which one of the following property scopes is not supported by PHP?

friendly
final
public
static
Which one of the following can be used to instantiate an object in PHP assuming class name to be Foo?

$obj = new $foo;
$obj = new foo;
$obj = new foo ();
obj = new foo ();
Which one of the following is the right way to define a constant?

constant PI = "3.1415"?;
const $PI = "3.1415"?;
constant PI = '3.1415';
const PI = '3.1415';
Which one of the following is the right way to call a class constant, given that the class is mathFunction?

echo PI;
echo mathFunction->PI;
echo mathFunction::PI;
echo mathFunction=PI;
Which one of the following is the right way to invoke a method?

$object->methodName();
object->methodName();
object::methodName();
$object::methodName();
Which of the following is/are the right way to declare a method? i) function functionName() { function body } ii) scope function functionName() { function body } iii) method methodName() { method body } iv) scope method methodName() { method body }

Only ii)
Only iv)
i) and ii)
iii) and iv)
Which of the following method scopes is/are not supported by PHP? i) private ii) final iii) static iv) abstract

Only ii)
Only iv)
ii) and iv)
None of the mentioned
Which method scope prevents a method from being overridden by a subclass?

Abstract
Protected
Final
Static
Which of the following statements is/are true about Constructors in PHP? i) PHP 4 introduced class constructors. ii) Constructors can accept parameters. iii) Constructors can call class methods or other functions. iv) Class constructors can call on other constructors.

ii) and iii)
All of the mentioned
None of the mentioned
ii), iii) and iv)
PHP recognizes constructors by the name..

classname()
_construct()
function _construct()
function __construct()
Which version of PHP introduced the instanceof keyword?

PHP 4
PHP 5
PHP 5.3
PHP 6
Which one of the following functions is used to determine whether a class exists?

exist()
exist_class()
class_exist()
__exist()
Which one of the following functions is used to determine object type?

obj_type()
type()
is_a()
is_obj()
Which one of the following keyword is used to inherit our subclass into a superclass?

extends
implements
inherit
include
In the PHP code given below, what is/are the properties?
  1.     <?php
  2.     class Example 
  3.     {
  4.         public $name;
  5.         function Sample()
  6.         {
  7.             echo "This is an example";
  8.         }
  9.     } 
  10.     ?>

echo "This is an example"?;
public $name;
class Example
function sample()
Which keyword allows class members (methods and properties) to be used without needing to instantiate a new instance of the class?

protected
final
static
private
Which keyword is used to refer to properties or methods within the class itself?

private
public
protected
$this