Olete.in
Articles
Mock Tests
🧪 CakePHP MCQ Quiz Hub
CakePHP MCQ
Choose a topic to test your knowledge and improve your CakePHP skills
1. Which CakePHP entities can the Bake console create?
Model
Controller
View
All of these
2. Which data retrieval function call is most suitable to build input select boxes?
find('select')
find('first')
find('list')
find('all')
3. Is it possible to define custom data retrieval methods and if so, where would you define them?
Yes, create a component
Yes, in the routes
Yes, in the model
No, good luck
4. Which of the following is an example of a model definition in CakePHP?
None of these
App::uses('AppModel', 'Model'); class Ingredient extends AppModel { public $name = 'Ingredient'; }
CakePlugin::loadAll(); // Loads all plugins at once CakePlugin::load('ContactManager'); //Loads a single plugin
class IngredientsController extends AppController { public function index() {
5. You want to generate three instances of a model form within the context of a view. What syntax is most correct to use with FormHelper::input() ? $i represents an incremented variable.
$this->Form->input("fieldname.$i.Modelname");
$this->Form->input("$i.Modelname.$i.fieldname");
$this->Form->input("Modelname.$i.fieldname");
$this->Form->input("$i.fieldname");
6. What kind of functionality does the Security Component provide?
Form tampering protection
Requiring that SSL be used
Restricting which HTTP methods the application accepts
All of these
7. Which file is processed first?
index.php
bootstrap.php
both (a) and (b)
None of These
8. In cakePHP 2.x , the recursive property defines:
how deep CakePHP should go to fetch associated model data via find(), and read() methods
how many records to fetch by data via find(), and read() methods
how many time the find(), and read() methods are called
None of these
9. What should be done before deploying a CakePHP application?
Set document root to app/webroot
Make sure data is sanitized and validated
Disable exception stack traces
All of the above
10. What is the AppController class?
It sets the initial configuration for plugins and caching.
It builds and manages paths to various components of the application.
It is responsible for converting the POST parameters into a request object.
It is the parent class to all of the application’s controllers.
11. What is a .ctp file?
Common Timing Protocol
Twig Template
PHP Container File
CakePHP Template
12. How is the AppController class defined?
public function beforeFilter() { parent::beforeFilter(); }
class AppController extends Controller { }
$data = array( 'color' => 'pink', 'type' => 'sugar'
None of these
13. The Bake console can be used to create:
models only
models and views only
models, views and controllers
models and controllers only
14. What does MVC stand for?
Module-vector-core
Maximum-velocity-counter
Modular-view-controlling
Model-view-controller
15. What is the default action for a controller?
index() function
_index() function
control() function
None of These
16. By default, what controller action will be invoked if the action is not specified in the URL?
index
view
default
add
17. Which data retrieval function will return one result only?
find('list', $options)
find('one', $options)
find('first', $options)
find('threaded', $options)
18. Which function is executed before every action in the controller.
firstFilter
beforeFilter
All of above
afterFilter
19. How will you include an element (header/footer etc.) within a layout?
<?php echo $this->element('element_name'); ?>
<?php include('element_name'); ?>
<?php echo $this->set('element_name'); ?>
<?php echo $this->include('element_name'); ?>
20. What is the name of the CLI console that comes with CakePHP and helps you get your project up and running fast by generating models, views, and controllers from templates.
grunt
rake
composer
bake
Submit