Tuesday, September 23, 2014

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)

6 comments:

  1. Thanks for sharing your view to our knowledge’s, its helps me plenty keep sharing…
    PHP Training Center in Chennai|PHP Course Chennai

    ReplyDelete
  2. Those guidelines additionally worked to become a good way to recognize that other people online have the identical fervor like mine to grasp great deal more around this condition.
    industrial safety courses in chennai

    ReplyDelete
  3. nice course. thanks for sharing this post this post harried me a lot.
    MCSE Training in Noida

    ReplyDelete
  4. It’s great to come across a blog every once in a while that isn’t the same out of date rehashed material. Fantastic read.
    Data science Course Training in Chennai |Best Data Science Training Institute in Chennai
    matlab training chennai | Matlab course in chennai

    ReplyDelete
  5. I have to voice my passion for your kindness giving support to those people that should have guidance on this important matter.
    MCSE Training in chennai | mcse training class chennai


    ReplyDelete
  6. wonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.
    AWS training in chennai | AWS training in anna nagar | AWS training in omr | AWS training in porur | AWS training in tambaram | AWS training in velachery

    ReplyDelete