MCQs | PHP/PHP Mcq Set 1 Sample Test,Sample questions

Question:
[:alpha:] can also be specified as ________

1.[A-Za-z0-9]

2.[A-za-z]

3.[A-z]

4.[a-z]


Question:
How many error levels are available in PHP?

1.14

2.15

3.16

4.17


Question:
How many functions does PHP offer for searching strings using POSIX style regular expression?

1.7

2.8

3.9

4.10


Question:
How many methods are available for the exception class?

1.5

2.6

3.7

4.8


Question:
How many predefined exceptions does SPL provide access to?

1.13

2.14

3.15

4.16


Question:
How many types of filtering are present in PHP?

1.3

2.2

3.4

4.None


Question:
If one intends to create a model that will be assumed by a number of closely related objects,which class must be used?

1.Normal class

2.Static class

3.Abstract class

4.Interface


Question:
If your object must inherit behavior from a number of sources you must use a/an

1.Interface

2.Object

3.Abstract class

4.Static class


Question:
PHP recognizes constructors by the name _____

1.classname()

2._construct()

3.function _construct()

4.function __construct()


Question:
POSIX implementation was deprecated in which version of PHP?

1.PHP 4

2.PHP 5

3.PHP 5.2

4.PHP 5.3


Question:
POSIX stands for _________

1.Portable Operating System Interface for Unix

2.Portable Operating System Interface for Linux

3.Portative Operating System Interface for Unix

4.Portative Operating System Interface for Linux


Question:
Say you want to report error concerned about fatal run-time,fatal compile-time error and core error which statement would you use?

1.error_reporting = E_ALL

2.error_reporting = E_ERROR | E_PARSE | E_CORE_ERROR

3.error_reporting = E_ERROR | E_COMPILE_WARNING | E_CORE_ERROR

4.error_reporting = E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR


Question:
The practice of creating objects based on predefined classes is often referred to as _____

1.class creation

2.object creation

3.object instantiation

4.class instantiation


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

1.Polymorphism

2.Inheritance

3.Encapsulation

4.Abstraction


Question:
What does SPL stand for?

1.Standard PHP Library

2.Source PHP Library

3.Standard PHP List

4.Source PHP List


Question:
What is the description of Error level E_ERROR?

1.Fatal run-time error

2.Near-fatal error

3.Compile-time error

4.Fatal Compile-time error


Question:
Which character does the error_reporting directive use to represent the logical operator NOT?

1./

2.!

3.~

4.^


Question:
Which feature allows us to call more than one method or function of the class in single instruction?

1.Typecasting

2.Method Including

3.Method adding

4.Method chaining


Question:
Which function initializes the constants necessary for using the openlog(),clodelog(),and syslog() functions?

1.define_variable()

2.define_log_variable()

3.log_variable()

4.define_syslog_variable()


Question:
Which function is responsible for sending a custom message to the system log?

1.systemlog()

2.syslog()

3.log_system()

4.sys_log()


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

1.protected

2.final

3.static

4.private


Question:
Which keyword is used to refer to properties or methods within the class itself?

1.private

2.public

3.protected

4.$this


Question:
Which logging option’s description is if an error occurs when writing to the syslog, send output to the system console?

1.LOG_CONS

2.LOG_NDELAY

3.LOG_ODELAY

4.LOG_PERROR


Question:
Which magic method is used to implement overloading in PHP?

1.__call

2.__invoke

3.__wakeup

4._unset


Question:
Which method is used to tweak an object’s cloning behavior?

1.clone()

2.__clone()

3._clone

4.object_clone()


Question:
Which method scope prevents a method from being overridden by a subclass?

1.Abstract

2.Protected

3.Final

4.Static


Question:
Which of the following statements causes PHP to disregard repeated error messages that occur within the same file and on the same line?

1.ignore_repeated_errors

2.ignore_repeat_error

3.repeatedly_ignore_error

4.repeated_error_ignore


Question:
Which of the following statements invoke the exception class?

1.throws new Exception();

2.throw new Exception();

3.new Exception();

4.new throws Exception();


Question:
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?

1.Abstraction

2.Polymorphism

3.Inheritance

4.Differential


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

1.$obj = new $foo;

2.$obj = new foo;

3.$obj = new foo ();

4.obj = new foo ();


Question:
Which one of the following does not describe a validating filter?

1.Are used to allow or disallow specific characters in a string

2.Are used to validate user input

3.Strict format rules

4.Returns the expected type on success or FALSE on failure


Question:
Which one of the following filter checks if the variable of the specified type exists?

1.filter_has_var

2.filter_var

3.filter_id

4.filter_var_array


Question:
Which one of the following filter is used to filter several variables with the same or different filters?

1.filter_var_array()

2.filter_var()

3.filter_input

4.filter_input_array


Question:
Which one of the following functions is used to determine object type?

1.obj_type()

2.type()

3.is_a()

4.is_obj()


Question:
Which one of the following functions is used to determine whether a class exists?

1.exist()

2.exist_class()

3.class_exist()

4.__exist()


Question:
Which one of the following is the right description for the method getMessage()?

1.Returns the message if it is passed to the constructor

2.Returns the message if it is passed to the class

3.Returns the message if it is passed to the file

4.Returns the message if it is passed to the object


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

1.echo PI;

2.echo mathFunction->PI;

3.echo mathFunction::PI;

4.echo mathFunction=PI;


Question:
Which one of the following is the right way to clone an object?

1.clone(targetObject);

2.destinationObject = clone targetObject;

3.destinationObject = _clone(targetObject);

4.destinationObject = clone(targetObject);


Question:
Which one of the following is the right way to define a constant?

1.constant PI = “3.1415”;

2.const $PI = “3.1415”;

3.constant PI = ‘3.1415’;

4.const PI = ‘3.1415’;


Question:
Which one of the following is the right way to invoke a method?

1.$object->methodName();

2.object->methodName();

3.object::methodName();

4.$object::methodName();


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

1.extends

2.implements

3.inherit

4.include


Question:
Which one of the following property scopes is not supported by PHP?

1.friendly

2.final

3.public

4.static


Question:
Which one of the following regular expression matches any string containing zero or one p?

1.p+

2.p*

3.P?

4.p#


Question:
Which version added the method getPrevious()?

1.PHP 4

2.PHP 5

3.PHP 5.1

4.PHP 5.3


Question:
Which version introduced the function error_get_last()?

1.PHP 4

2.PHP 5

3.PHP 5.2

4.PHP 5.3


Question:
Which version of PHP introduced E_STRICT Error level?

1.PHP 4

2.PHP 5

3.PHP 5.2

4.PHP 5.3


Question:
Which version of PHP introduced the advanced concepts of OOP?

1.PHP 4

2.PHP 5

3.PHP 5.3

4.PHP 6


Question:
Which version of PHP introduced the instanceof keyword?

1.PHP 4

2.PHP 5

3.PHP 5.3

4.PHP 6


Question:
Which version of PHP was added with Exception handling?

1.PHP 4

2.PHP 5

3.PHP 5.3

4.PHP 6


Question:
You can extend the exception base class,but you cannot override any of the preceding methods because the are declared as_________

1.protected

2.final

3.static

4.private


More MCQS

  1. PHP Mcq Set 1
  2. PHP Mcq Set 2
  3. PHP Mcq Set 3
  4. PHP Mcq Set 4
  5. Current affairs mcq php
  6. Current affairs mcq php set 2
  7. Current affairs mcq php set 3
  8. PHP MCQ
  9. PHP MCQ– Basics
  10. PHP Mcq – Functions
  11. PHP Mcq Arrays
  12. PHP Mcq– Basics of Object-Oriented PHP
  13. PHP Mcq – Error Handling
  14. PHP Basics Mcq Questions
Search