Sample questions
Question 1Medium
The goal of each controller in Symfony is to return a
- Response object
- Request Object
- PHP Object
- None
Answer: A. Response object
Explanation
A controller is a PHP function you create that takes information from the HTTP request and constructs and returns an HTTP response (as a Symfony2 Response object). The response could be an HTML page, an XML document, a serialized JSON array, an image, a redirect, a 404 error or anything else you can dream up.
Step-by-step solution
- Controller returns HTTP response as Response object.
- Response object handles different types of output.
- Correct answer is Response object.
- Final answer: A (Response object).
Why the other options are wrong
- B. A Request object is what the controller receives, not what it returns.
- C. A generic PHP object is not what a Symfony controller must return.
- D. None is wrong because a controller returns a Response object.
Tip: Remember, controllers always return a Response object.
Question 2Medium
The filename 'Zend/Db/Table.php' must map to the class name___?
- Zend table
- Zend_Db_Table
Answer: B. Zend_Db_Table
Explanation
The Zend_Db_Table class is an object-oriented interface to database tables. It provides methods for many common operations on tables. The base class is extensible, so you can add custom logic.
Step-by-step solution
- In Zend Framework, each slash in the file path becomes an underscore in the class name.
- So Zend/Db/Table.php maps to the class Zend_Db_Table.
- Zend db table, option B, is that name with the underscores read as spaces, the correct answer.
Why the other options are wrong
- A. Zend table drops the Db part of the path, so a segment is missing.
Tip: In Zend-style names each folder in the path becomes a word, joined by underscores.
Question 3Medium
The Request class symfony is a simple object-oriented representation of the____
- HTTP request message
- HTML request message
- PHP request message
- TCP request message
Answer: A. HTTP request message
Explanation
The Request class symfony is a simple object-oriented representation of the HTTP request message.
Step-by-step solution
- The Request class in Symfony handles incoming web requests.
- HTTP is the protocol used for transmitting data on the web.
- Symfony's Request class represents the HTTP request message as an object.
- This allows developers to access and manipulate request data easily.
- Therefore, the correct answer is HTTP request message.
Why the other options are wrong
- B. HTML is a markup language for pages; the Request class represents an HTTP message.
- C. PHP is the language itself; the Request class represents an HTTP request, not a PHP request message.
- D. TCP is the transport layer; the Request class models the HTTP request message.
Tip: Remember: Symfony's Request class deals with HTTP requests, not HTML or PHP.
Question 4Medium
Which of the following are php frameworks?
- Zend framework
- Symphony framework
- Cake php framework
- All of these.
Answer: D. All of these.
Explanation
A framework is designed to provide a structure for common elements (database interaction, presentation layer, application logic) so you spend less time writing up database interface code or presentation-layer interfaces and more time writing the application itself.
Step-by-step solution
- The question asks which of the listed names are PHP frameworks.
- Zend framework is a PHP framework.
- Symfony (written Symphony in the question) is a PHP framework.
- CakePHP is a PHP framework, so all three are right and the correct answer is option D, All of these.
Why the other options are wrong
- A. Zend is a real PHP framework, but it is not the full answer on its own; the question needs all of the named options.
- B. Symfony is a real PHP framework, but on its own it is not the full answer; All of these is the right choice.
- C. CakePHP is a real PHP framework, but on its own it is not the full answer; All of these is the right choice.
Tip: When All of these is an option, check every listed item; it is right only if every item is correct.
Question 5Medium
Validators used with zend form should implement which class?
- Zend_form_ValidatorAbstract
- Zend_Validate_Abstract
- Zend_validate_Interface
- Zend form validate interface
Answer: C. Zend_validate_Interface
Explanation
Zend_Validate_Interface defines two methods, isValid() and getMessages(), that may be implemented by user classes in order to create custom validation objects. An object that implements Zend_Validate_Interface interface may be added to a validator chain with Zend_Validate::addValidator().
Step-by-step solution
- The question asks which interface a custom Zend form validator must implement.
- Zend_Validate_Interface defines the isValid() and getMessages() methods.
- Zend_Validate_Abstract is a base class, not the interface that validators implement.
- The correct answer is option C, Zend_validate_Interface.
Why the other options are wrong
- A. Zend_form_ValidatorAbstract is not the interface a validator implements.
- B. Zend_Validate_Abstract is a base class, not the interface named in the question.
- D. This is not a class or interface name in Zend.
Tip: Interfaces list the methods a class must have; pick the interface, not the base class.
Question 6Medium
In Symfony, the routing configuration can be written in
- YAML
- PHP
- XML
- All of the above
Answer: D. All of the above
Explanation
In symphony ,the routing configuration can be written in YAML, in PHP and in Xml.
Step-by-step solution
- The question asks which formats Symfony accepts for routing configuration.
- The explanation says Symfony routing can be written in YAML, in PHP and in XML.
- All three are listed, so option D, All of the above, is the answer.
Why the other options are wrong
- A. YAML is valid, but PHP and XML are valid too.
- B. PHP is valid, but YAML and XML are valid too.
- C. XML is valid, but YAML and PHP are valid too.
Tip: When every listed choice is true, All of the above is the answer.
Question 7Medium
ZendAcl supports __ inheritance among resource objects.
- Cyclic
- Multiple
- No
- Single
Answer: D. Single
Explanation
ZendAcl supports single inheritance among resource objects, meaning a resource can only have one parent resource.
Step-by-step solution
- The question asks what kind of inheritance Zend ACL supports among resource objects.
- The explanation says a resource can have only one parent resource.
- One parent per resource is single inheritance, which is option D.
Why the other options are wrong
- A. Cyclic would mean inheritance loops back on itself, which is not described.
- B. Multiple would mean a resource can have many parents, but the explanation says one.
- C. No would mean no inheritance at all, but inheritance is supported.
Tip: Single means one parent; multiple means many parents.
Question 8Medium
In CakePHP, user can define their own routes in the
- app/Config/routes.php
- app/Config/temp.php
- app/Config/url.php
- app/Config/connect.php
Answer: A. app/Config/routes.php
Explanation
CakePHP defines custom routes in app/Config/routes.php. The other file names are not CakePHP's routing file.
Step-by-step solution
- CakePHP routes are defined in app/Config/routes.php.
- The $routes array in this file lets you set custom routing rules.
- Wildcards or regular expressions can be used to define these routes.
- Other files like temp.php, url.php, and connect.php do not handle routing.
- So the correct route definition file is app/Config/routes.php.
Why the other options are wrong
- B. temp.php is not the CakePHP routes file; user routes are defined in routes.php.
- C. url.php is not the CakePHP routes file; user routes are defined in routes.php.
- D. connect.php is not the routes file; user routes are defined in routes.php.
Tip: Remember: routes.php is where you set up URL routing in CakePHP.
Question 9Medium
Which method of zend locale will check if given string is locale?
- IsLocale
- areLocale
Answer: A. IsLocale
Explanation
IsLocale checks if the given string is a valid locale identifier.
Step-by-step solution
- IsLocale method checks if a string is a valid locale identifier.
- Valid locales are like 'en_US' or 'fr_FR', so IsLocale confirms this.
- Other methods like areLocale do not perform this check directly.
- Therefore, the correct answer is IsLocale.
- Final Answer: A (IsLocale).
Why the other options are wrong
- B. areLocale is a different name from the method asked for; the checking method here is IsLocale.
Tip: Remember, IsLocale is used to validate locale strings directly.
Question 10Medium
By default, the routing configuration file in a Symfony2 application is located at
- app/config/routing.yml
- app/yaml/routing.yml
- app/config_route/routing.yml
- app/config/routing.config
Answer: A. app/config/routing.yml
Explanation
In a Symfony 2 project, the default routing file is app/config/routing.yml. The other paths are not the default.
Step-by-step solution
- Symfony2 uses YAML format for routing configuration.
- The default location for routing.yml is app/config/routing.yml.
- Other options have incorrect folder names or file extensions.
- Option A matches the standard Symfony2 directory structure.
- Final answer: app/config/routing.yml.
Why the other options are wrong
- B. app/yaml is not the default folder; the routing file sits in app/config.
- C. app/config_route is not the default folder; the routing file sits in app/config.
- D. routing.config has the wrong extension; the default file is routing.yml.
Tip: Remember, Symfony2 uses YAML files in app/config for most configurations.
Practise all 10 questions free
The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.
Open this topic in the app →