PHP Constructors Multiple Choice Questions
1) PHP recognises constructors by the name . . . . .
A) _construct
B) __construct
C) __constructor
D) _constructor
2) In . . . . . constructors, it is important to remember that you have to call the parent constructor explicitly.
A) Singleton
B) secure
C) public
D) subclass
3) Constructor and destructor methods have no . . . . . . and are called automatically - they cannot be called explicitly and consequently their declarations need no access specifier.
A) parameters
B) destructor
C) return value
D) aproval
4) Unlike constructors, you cannot pass information to a destructor, because you are never sure when its going to be run.
A) True
B) False
5) You can invoke class constructors that don’t have any relation to the instantiated object by simply prefacing _constructor with the class name like
A) classname::__construct()
B) classname:__construct()
C) classname=>__construct()
D) classname->__construct()
6) . . . . . . is a class which can only be instantiated once. You can effectively only have one object per . . . . . class in an application.
A) Constructor, Singleton
B) Singleton, Constructor
C) Singleton, Singleton
D) Loader, Loader
7) Even if you don’t delete the object yourself using . . . . . , PHP still calls the destructor when it determines that the object is no longer used.
A) destructor
B) del()
C) rem()
D) unset()
8) You can overwrite a Singleton with the wrong kind of data.
A) True
B) False
9)
Because the constructor is called each time you create an object, this code produces the following output:
A)
Constructor called with parameter One
Constructor called with parameter Two
B)
Constructor is called with parameter One
C)
Constructor is called with parameter One
Constructor is called with parameter Two
D)
Constructor is called with parameter Two
10) PHP have not yet supported constructor overloading.
A) True
B) False
Answers
1) PHP recognises constructors by the name . . . . .
A) _construct
B) __construct
C) __constructor
D) _constructor
2) In . . . . . constructors, it is important to remember that you have to call the parent constructor explicitly.
A) Singleton
B) secure
C) public
D) subclass
3) Constructor and destructor methods have no . . . . . . and are called automatically - they cannot be called explicitly and consequently their declarations need no access specifier.
A) parameters
B) destructor
C) return value
D) aproval
4) Unlike constructors, you cannot pass information to a destructor, because you are never sure when its going to be run.
A) True
B) False
5) You can invoke class constructors that don’t have any relation to the instantiated object by simply prefacing _constructor with the class name like
A) classname::__construct()
B) classname:__construct()
C) classname=>__construct()
D) classname->__construct()
6) . . . . . . is a class which can only be instantiated once. You can effectively only have one object per . . . . . class in an application.
A) Constructor, Singleton
B) Singleton, Constructor
C) Singleton, Singleton
D) Loader, Loader
7) Even if you don’t delete the object yourself using . . . . . , PHP still calls the destructor when it determines that the object is no longer used.
A) destructor
B) del()
C) rem()
D) unset()
8) You can overwrite a Singleton with the wrong kind of data.
A) True
B) False
9)
Because the constructor is called each time you create an object, this code produces the following output:
A)
Constructor called with parameter One
Constructor called with parameter Two
B)
Constructor is called with parameter One
C)
Constructor is called with parameter One
Constructor is called with parameter Two
D)
Constructor is called with parameter Two
10) PHP have not yet supported constructor overloading.
A) True
B) False
Answers