CakePHP MCQ Questions & Answers
CakePHP MCQs : This section focuses on "CakePHP" of PHP Framework. These Multiple Choice Questions (MCQ) should be practiced to improve the CakePHP skills required for various interviews (campus interviews, walk-in interviews, company interviews), placements, entrance exams and other competitive examinations.
1. Which of the following is true about cakephp?
A. CakePHP is an open source MVC framework.
B. CakePHP makes developing, deploying and maintaining applications much easier.
C. CakePHP has a number of libraries to reduce the overload of most common tasks.
D. All of the above
View Answer
Ans : D
Explanation: CakePHP is an open source MVC framework. It makes developing, deploying and maintaining applications much easier. CakePHP has a number of libraries to reduce the overload of most common tasks.
2. Which of the following is not an advantage of CakePHP?
A. Hard CRUD
B. Built-in Validation
C. Search Engine Friendly URLs
D. MVC Framework
View Answer
Ans : A
Explanation: Easy CRUD (Create, Read, Update, Delete) Database Interactions.
3. The view uses ___________ to generate the response body and headers.
A. Helpers
B. Cells
C. Helpers and Cells
D. None of the above
View Answer
Ans : C
Explanation: The view uses Helpers and Cells to generate the response body and headers.
4. Which folder holds the Cake console executables?
A. config
B. bin
C. logs
D. plugins
View Answer
Ans : B
Explanation: The bin folder holds the Cake console executables.
5. Which methods cannot be accessed with routing?
A. Public
B. Private
C. Protected
D. Both B and C
View Answer
Ans : D
Explanation: The /users /view maps to the view() method of the UsersController out of the box. Protected or private methods cannot be accessed with routing.
6. Which directory is the public document root of your application?
A. webroot
B. vendor
C. tmproot
D. testroot
View Answer
Ans : A
Explanation: The webroot directory is the public document root of your application. It contains all the files you want to be publically reachable.
7. Which function is used to read the configuration for the environment you need and build your application?
A. environment()
B. env()
C. config.env()
D. config.environment()
View Answer
Ans : B
Explanation: You can make use of env() function to read the configuration for the environment you need and build your application.
8. Configuration for Email defaults is created using ?
A. config()
B. configTransport()
C. configEmail()
D. Both A and B
View Answer
Ans : D
Explanation: Configuration for Email defaults is created using config() and configTransport().
9. Can we use extension .ctp while providing the name of the View file?
A. Yes
B. No
C. Can be yes or no
D. Can not say
View Answer
Ans : B
Explanation: Don’t use extension .ctp while providing the name of the View file.
10. Which method is called after the view has been rendered, but before the layout rendering has started?
A. Helper::afterRender(Event $event, $viewFile)
B. Helper::beforeLayout(Event $event, $layoutFile)
C. Helper::afterLayout(Event $event, $layoutFile)
D. Helper::afterRenderFile(Event $event, $viewFile, $content)
View Answer
Ans : A
Explanation: Helper::afterRender(Event $event, $viewFile) => This method is called after the view has been rendered, but before the layout rendering has started.
11. The _______ method will take the name of the database table as an argument.
A. put()
B. set()
C. get()
D. select()
View Answer
Ans : C
Explanation: The get() method will take the name of the database table as an argument.
12. How many types of Authentication CakePHP supports?
A. 2
B. 3
C. 4
D. 5
View Answer
Ans : B
Explanation: Authentication is the process of identifying the correct user. CakePHP supports three types of authentication. FormAuthenticate, BasicAuthenticate, DigestAuthenticate.
13. Which allows you to authenticate users based on form POST data?
A. FormAuthenticate
B. BasicAuthenticate
C. DigestAuthenticate
D. All of the above
View Answer
Ans : A
Explanation: FormAuthenticate : It allows you to authenticate users based on form POST data. Usually, this is a login form that users enter information into. This is default authentication method.
14. Which allows you to authenticate users using Digest HTTP authentication?
A. FormAuthenticate
B. BasicAuthenticate
C. DigestAuthenticate
D. None of the above
View Answer
Ans : C
Explanation: DigestAuthenticate : It allows you to authenticate users using Digest HTTP authentication.
15. What is the data type for exceptionRenderer?
A. int
B. bool
C. array
D. string
View Answer
Ans : D
Explanation: The class responsible for rendering uncaught exceptions. If you choose a custom class, you should place the file for that class in src/Error. This class needs to implement a render() method.
16. What is true about errorLevel?
A. The level of errors you are interested in capturing
B. Include stack traces for errors in log files.
C. The class responsible for rendering uncaught exceptions.
D. An array of exception class names that should not be logged.
View Answer
Ans : A
Explanation: errorlevel : The level of errors you are interested in capturing. Use the built-in php error constants, and bitmasks to select the level of error you are interested in.
17. The log() function is provided by the?
A. Logging
B. LogTrait
C. datalog
D. cronjob
View Answer
Ans : B
Explanation: The log() function is provided by the LogTrait, which is the common ancestor for almost all CakePHP classes.
18. What is the first file that gets loaded when you run an application using a cakephp?
A. index.php
B. config.php
C. bootstrap.php
D. core.php
View Answer
Ans : A
Explanation: index.php is the first file that gets loaded when you run an application using a cakephp.
19. Which of email transports can be used in CakeEmail?
A. Only Mail and Smtp
B. Mail, Smtp and your own
C. Only Mail
D. Only Smtp
View Answer
Ans : B
Explanation: Mail, Smtp and your own of email transports can be used in CakeEmail
20. Which by is not a core find type provided by CakePHP?
A. first
B. all
C. active
D. threaded
View Answer
Ans : C
Explanation: Active is not a core find type provided by CakePHP.
Discussion