1. Question: What is wrong with the following code?
    <?php
    
    function duplicate($obj) {
    	$newObj = $obj;
    	return $newObj;
    }
    
    $a = new MyClass();
    
    $a_copy = duplicate($a);
    
    $a->setValue(10);
    $a_copy->setValue(20);
    
    ?>

    A
    You must use return &$newObj instead

    B
    There is nothing wrong with this code

    C
    duplicate() must accept its parameter by reference

    D
    You must use the clone operator to make a copy of an object

    E
    duplicate() must return a reference

    Note: Not available
    1. Report
  2. Question: How can you modify the copy of an object during a clone operation?

    A
    Put the logic in the object's constructor to alter the values

    B

    C
    Implement the object's __clone() method

    D

    E

    Note: Not available
    1. Report
  3. Question: What is the primary difference between a method declared as static and a normal method?

    A
    Static methods can only be called using the :: syntax and never from an instance

    B
    Static methods do not provide a reference to $this

    C
    Static methods cannot be called from within class instances

    D

    E
    There is no functional difference between a static and non-static method

    Note: Not available
    1. Report
  4. Question: What is the output of the following script?

    <?php

    class ClassOne {
    protected $a = 10;

    public function changeValue($b) {
    $this->a = $b;
    }
    }

    class ClassTwo extends ClassOne {

    protected $b = 10;

    public function changeValue($b) {
    $this->b = 10;
    parent::changeValue($this->a + $this->b);
    }

    public function displayValues() {
    print "a: {$this->a}, b: {$this->b}\n";
    }
    }

    $obj = new ClassTwo();

    $obj->changeValue(20);
    $obj->changeValue(10);

    $obj->displayValues();

    ?>

    A

    B

    C

    D

    E
    a: 10, b: 10

    Note: Not available
    1. Report
  5. Question: The ______ keyword is used to indicate an incomplete class or method, which must be further extended and/or implemented in order to be used.

    A

    B

    C

    D

    E

    Note: Not available
    1. Report
  6. Question: In PHP 5's object model, a class can have multiple ______ but only a single direct
    ________.

    A

    B

    C

    D

    E

    Note: Not available
    1. Report
  7. Question: The _______ method will be called automatically when an object is represented as a string.

    A

    B

    C
    __value()

    D

    E

    Note: Not available
    1. Report
  8. Question: When an object is serialized, which method will be called, automatically, providing your object with an opportunity to close any resources or otherwise prepare to be serialized?

    A

    B

    C

    D

    E

    Note: Not available
    1. Report
  9. Question: Which two internal PHP interfaces provide functionality which allow you to treat an object like an array?

    A
    iteration

    B
    arrayaccess

    C

    D

    E
    array

    Note: Not available
    1. Report
  10. Question: Which scope is present in method not in field?

    A
    public

    B
    private

    C
    abstract

    D
    protected

    Note: Not available
    1. Report
Copyright © 2024. Powered by Intellect Software Ltd