PHP 4

COEP
Lets Crack Online Exam

IT Interview Exam Paper: PHP 4

Subject: PHP 4

Part 4: List for questions and answers of PHP

 

Q1. 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

 

Q2. 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?

a) Abstraction

b) Polymorphism

c) Inheritance

d) Differential

 

Q3. 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

 

Q4. Which one of the following property scopes is not supported by PHP?

a) friendly

b) final

c) public

d) static

 

Q5. Which one of the following can be used to instantiate an object in PHP assuming class name to be Foo?

a) $obj = new $foo;

b) $obj = new foo;

c) $obj = new foo ();

d) obj = new foo ();

 

Q6. Which one of the following is the right way to define a constant?

a) constant PI = “3.1415”;

b) const $PI = “3.1415”;

c) constant PI = ‘3.1415’;

d) const PI = ‘3.1415’; 

 

Q7. Which one of the following is the right way to call a class constant, given that the class is mathFunction?

a) echo PI;

b) echo mathFunction->PI;

c) echo mathFunction::PI;

d) echo mathFunction=PI;

 

Q8. Which one of the following is the right way to invoke a method?

a) $object->methodName();

b) object->methodName();

c) object::methodName();

d) $object::methodName();

 

Q9. 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

a) Only ii)

b) Only iv)

c) i) and ii)

d) iii) and iv)

 

Q10. Which of the following method scopes is/are not supported by PHP?

i)private

ii)final

iii)static

iv)abstract

a) Only ii)

b) Only iv)

c) ii) and iv)

d) None of the mentioned


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

a) Abstract

b) Protected

c) Final

d) Static 

 

Q12. 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

a) ii) and iii)

b) All of the mentioned

c) None of the mentioned

d) ii), iii) and iv)

 

Q13. PHP recognizes constructors by the name..

a) classname()

b) _construct()

c) function _construct()

d) function __construct()

 

Q14. Which version of PHP introduced the instanceof keyword?

a) PHP 4

b) PHP 5

c) PHP 5.3

d) PHP 6

 

Q15. Which one of the following functions is used to determine whether a class exists?

a) exist()

b) exist_class()

c) class_exist()

d) __exist()

 

Q16. Which one of the following functions is used to determine object type?

a) obj_type()

b) type()

c) is_a()

d) is_obj()

 

Q17. Which one of the following keyword is used to inherit our subclass into a superclass?

a) extends

b) implements

c) inherit

d) include 

 

Q18. In the PHP code given below, what is/are the properties?

<?php

class Example

{

public $name;

function Sample()

{

echo “This is an example”;

}

}

?>

a) echo “This is an example”;

b) public $name;

c) class Example

d) function sample()

 

Q19. Which keyword is used to refer to properties or methods within the class itself?

a) private

b) public

c) protected

d) $this

 

Q20. Which keyword allows class members (methods and properties) to be used without needing to instantiate a new instance of the class?

a) protected

b) final

c) static

d) private 

 

Part 4: List for questions and answers of PHP

 

Q1. Answer: c

 

Q2. Answer: b

 

Q3. Answer: d

 

Q4. Answer: a

 

Q5. Answer: c

 

Q6. Answer: d

 

Q7. Answer: c

 

Q8. Answer: a

 

Q9. Answer: c

 

Q10. Answer: d

 

Q11. Answer: c

 

Q12. Answer: b

 

Q13. Answer: d

 

Q14. Answer: b

 

Q15. Answer: c

 

Q16. Answer: c

 

Q17. Answer: a

 

Q18. Answer: b

 

Q19. Answer: d

 

Q20. Answer: c