PHP test : object oriented PHP-1

THEORY


Que. 1 Which method scope prevents a method from being overridden by a subclass?

a) Abstract
b) Protected
c) Final
d) Static
Que.2  PHP recognizes constructors by the name..

a) classname()
b) _construct()
c) function _construct()
d) function __construct()
Que 3  The practice of creating objects based on predefined classes is often referred to as..

a) class creation
b) object creation
c) object instantiation
d) class instantiation
Que.4  The practice of separating the user from the true inner workings of an application through well-known interfaces is known as..

a) Polymorphism
b) Inheritance
c) Encapsulation
d) Abstraction
Que.5  Which version of PHP introduced the instance of keyword?

a) PHP 4
b) PHP 5
c) PHP 5.3
d) PHP 6
PROGRAMS :
Que.1  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.     ?>
a) echo “This is an example”;
b) public $name;
c) class Example
d) function sample()

Que.2  What will be the output of the following PHP code?
  1. <?php
  2. class MyClass
  3. {
  4. }
  5.  
  6. $a = new MyClass;
  7. var_dump(!($a instanceof stdClass));
  8. ?>
a) bool(true)
b) bool(false)
c) Error
d) None of the above


Que. 3  What will be the output of the following PHP code?
  1. <?php
  2. class ParentClass
  3. {
  4. }
  5.  
  6. class MyClass extends ParentClass
  7. {
  8. }
  9.  
  10. $a = new MyClass;
  11.  
  12. var_dump($a instanceof MyClass);
  13. var_dump($a instanceof ParentClass);
  14. ?>
a) bool(false)
bool(false)


b) bool(true)
bool(true)


c) bool(false)
bool(true)


d) bool(true)
bool(false)


Que 4  What will be the output of the following code?
  1.     <?php 
  2.     $foo = 'Bob';              
  3.     $bar = &$foo;              
  4.     $bar = "My name is $bar";  
  5.     echo $bar;
  6.     echo $foo;
  7.     ?>
a) Error
b) My name is BobBob
c) My name is BobMy name is Bob
d) My name is Bob Bob


Que. 5  What will be the output of the following PHP code?
  1. <?php
  2. interface MyInterface
  3. {
  4. }
  5.  
  6. class MyClass implements MyInterface
  7. {
  8. }
  9.  
  10. $a = new MyClass;
  11.  
  12. var_dump($a instanceof MyClass);
  13. var_dump($a instanceof MyInterface);
  14. ?>
a) bool(false)
bool(false)


b) bool(true)
bool(true)


c) bool(false)
bool(true)


d) bool(true)
bool(false)

No comments:

Post a Comment

Featured post

A23 Rummy - Safe Secure Gaming Platform

A23 Rummy is a popular online rummy platform in India. It is owned and operated by Head Digital Works Private Limited. The platform offers...