Yii is an open source, object-oriented, component-based MVC PHP web application framework.
Yii PHP Framework MCQs: This section contains multiple-choice questions and answers on the various topics of Yii PHP Framework. Practice these MCQs to test and enhance your skills on Yii PHP Framework.
List of Yii PHP Framework MCQs
1. Yii is a ____ framework.
- PHP
- JavaScript
- Python
- Java
Answer: A) PHP
Explanation:
Yii is a PHP framework.
2. Which architecture does the Yii framework follows?
- MVVM
- MVC
- MVP
Answer: B) MVC
Explanation:
Yii framework follows MVC architecture.
3. Is Yii framework purely object-oriented?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, Yii framework is purely object-oriented.
4. Is the Yii framework an open-source framework?
- Yes
- No
Answer: A) Yes
Explanation:
Yii framework is an open-source framework.
5. Which code generation tool does Yii uses?
- Springboot
- CLI
- Code Igniters
- Gii
Answer: D) Gii
Explanation:
Gii is the code generation toolkit.
6. Does the Yii framework provides the feature of both RDBMS and NoSQL?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, the Yii framework provides the feature of both RDBMS and NoSQL.
7. Data structures are represented, and mechanisms for accessing and altering data are provided by ____.
- View
- Controller
- Model
Answer: C) Model
Explanation:
Data structures are represented, and mechanisms for accessing and altering data are provided by the model.
8. ____ is responsible for presenting the user interface, including presentation logic and data presentation.
- View
- Controller
- Model
Answer: A) View
Explanation:
View is responsible for presenting the user interface, including presentation logic and data presentation.
9. ____ handles user requests and coordinates the model’s and view’s interaction.
- View
- Controller
- Model
Answer: B) Controller
Explanation:
The controller handles user requests and coordinates the model’s and view’s interaction.
10. The ____ folder contains all.js and.css files mentioned on the web page.
- Assets
- Config
- Model
- View
Answer: A) Assets
Explanation:
The assets folder contains all.js and.css files mentioned on the web page.
11. The ____ folder includes all of the third-party packages that Composer manages.
- Model
- Config
- Vendor
Answer: D) Vendor
Explanation:
The vendor folder includes all of the third-party packages that Composer manages.
12. ____ are the greatest location to define global constants.
- Widgets
- Moules
- Entry Scripts
- Composer
Answer: D) Entry Scripts
Explanation:
Entry scripts are the greatest location to define global constants.
13. The constant ____ is used to enable or deactivate debugging in a Yii application.
- YII_ENV
- YII DEBUG
- YII_ENABLE_ERROR_HANDLER
Answer: B) YII DEBUG
Explanation:
The constant YII DEBUG is used to enable or deactivate debugging in a Yii application.
14. When the variable YII DEBUG is set to ____, the program displays detailed error messages.
- True
- False
- None
Answer: A) True
Explanation:
When the variable YII DEBUG is set to true, the program displays detailed error messages.
15. ____ is a constant that specifies the environment in which a Yii application runs, such as “development” or “production.”
- YII_ENV
- YII DEBUG
- YII_ENABLE_ERROR_HANDLER
Answer: A) YII_ENV
Explanation:
YII ENV is a constant that specifies the environment in which a Yii application runs, such as “development” or “production.”
16. When YII ENABLE ERROR HANDLER is set to ____, PHP’s default error handling method is utilized.
- True
- False
- None
Answer: B) False
Explanation:
When YII ENABLE ERROR HANDLER is set to false, PHP’s default error handling method is utilized.
17. Which of the following is the controller’s default action, and is commonly used to show a list of records?
- ActionShow()
- Actioncreate()
- ActionView()
- ActionIndex()
Answer: D) ActionIndex()
Explanation:
actionIndex() is the controller’s default action, and is commonly used to show a list of records.
18. You can view a single record in detail with ____ action.
- Viewaction()
- Actionsee()
- actionView()
Answer: C) Actionsee()
Explanation:
You can view a single record in detail with actionview () action.
19. ____ Action is used for setting a new record.
- CreateAction()
- actionCreateNew()
- actionNew()
- actionCreate()
Answer: D) actionCreate()
Explanation:
actionCreate() is used for setting a new record.
20. A ____ in Yii is a mapping between a URL pattern and a controller action.
- Templating engine
- Route
- Controller
- Composer
Answer: B) Route
Explanation:
A route in Yii is a mapping between a URL pattern and a controller action.
21. Action ID can contain ____.
- English letter in lowercase
- Digits
- Hyphens
- Underscores
- All of the above
Answer: E) All of the above
Explanation:
Action ID can contain:
- English letter in lowercase
- Digits
- Hyphens
- Underscores
22. How many types of actions are there in the Yii framework?
- 5
- 4
- 3
- 2
Answer: D) 2
Explanation:
Two types of actions are there in the Yii framework: Inline and standalone.
23. Which of the following action is defined in the controller class?
- Inline
- Standalone
Answer: A) Inline
Explanation:
Inline actions are defined in the controller class.
24. In the Yii framework, an ____ method is a public method in a controller class that is in charge of processing a request and creating a response.
- Model
- Controller
- Action
Answer: C) Action
Explanation:
In the Yii framework, an action method is a public method in a controller class that is in charge of processing a request and creating a response.
25. A ____ is a class in the Yii framework that represents a data item and specifies the logic for communicating with data storage, such as a database.
- Model
- Controller
- Action
Answer: A) Model
Explanation:
A model is a class in the Yii framework that represents a data item and specifies the logic for communicating with data storage, such as a database.
26. Which of the following method updates data in the data store based on the circumstances stated?
- Update()
- UpdateAll()
- Validate()
Answer: B) UpdateAll()
Explanation:
UpdateAll() method, Updates data in the data store based on the circumstances stated.
27. In the Yii framework, ____ are used to describe which properties of a model should be evaluated during validation.
- Possibilities
- Events
- Cases
- Scenarios
Answer: D) Scenarios
Explanation:
In the Yii framework, scenarios are used to describe which properties of a model should be evaluated during validation.
28. A ____ is a piece of reusable client-side programming that includes HTML, CSS, and JS.
- View
- Widget
- Template
Answer: B) Widget
Explanation:
A widget is a piece of reusable client-side programming that includes HTML, CSS, and JS.
29. To utilize a widget, we use which of the following method?
- Widget ()
- Wid()
- Use_widget()
Answer: A) Widget()
Explanation:
To utilize a widget, use the “widget ()” function.
30. ____ are mini-applications that may be inserted into the main application and contain their controllers, models, views, and assets.
- Units
- Modules
- Components
- Template
Answer: B) Modules
Explanation:
Modules are mini-applications that may be inserted into the main application and contain their controllers, models, views, and assets.
31. When the module is being initialized, which of the following method is invoked?
- Initialized ()
- Start ()
- New ()
- Init ()
Answer: D) Init ()
Explanation:
When the module is being initialized, Init () method is invoked.
32. Which of the following function returns the module to which a component belongs?
- getModules()
- get()
- getModule()
Answer: C) getModule()
Explanation:
getModule() function returns the module to which a component belongs.
33. Which of the following function returns an array of all the modules declared in the application?
- getModules()
- get()
- getModule()
Answer: A) getModules()
Explanation:
getModules () function returns an array of all the modules declared in the application.
34. Is getModules () and getModule () both are same?
- Yes
- No
Answer: B) No
Explanation:
No, they are not the same, getModules () function returns an array of all the modules declared in the application, whereas the getModule() function returns the module to which a component belongs.
35. To render a view, ____ method is implemented.
- Render ()
- Use ()
- Display ()
- Create ()
Answer: A) Render ()
Explanation:
To render a view, the render() method is implemented.
36. ____ function is used to render a partial view, which is a view piece that may be reused across numerous pages.
- Render_limited()
- LimitedRender()
- renderPartial()
Answer: C) renderPartial()
Explanation:
renderPartial() function is used to render a partial view, which is a view piece that may be reused across numerous pages.
37. ____ in the Yii framework are static files such as JavaScript, CSS, pictures, and fonts that are used to improve an application’s visual and interactive characteristics.
- Template
- Static
- Component
- Assets
Answer: D) Assets
Explanation:
Assets in the Yii framework are static files such as JavaScript, CSS, pictures, and fonts that are used to improve an application’s visual and interactive characteristics.
38. ____ are third-party components that offer new features to your program.
- Extension
- Plugin
- Extender
Answer: A) Extension
Explanation:
Extension are third-party components that offer new features to your program.
39. Which of the following HTTP method is used to gather data without altering it in any way?
- GET
- POST
- PUT
- PATCH
Answer: A) GET
Explanation:
GET HTTP method is used to gather data without altering it in any way.
40. Which of the following HTTP method is employed in the creation of new resources as well as the update of current ones?
- GET
- POST
- PUT
Answer: B) POST
Explanation:
POST HTTP method is employed in the creation of new resources as well as the update of current ones.
41. Which of the following function is used to generate URLs for a certain activity?
- CreateURL()
- NewURL()
- InitURL()
Answer: A) CreateURL()
Explanation:
CreateURL() function is used to generate URLs for a certain activity.
42. Suppose you want to add new URL rules to the URL manager component, then which of the following method you will use?
- Rules_new()
- New_Rules()
- AddRules()
Answer: C) AddRules()
Explanation:
addRules() method, add new URL rules to the URL manager component.
43. ____ function generates the form’s opening element and returns the HTML code for it.
- beginForm()
- endForm()
- Form()
Answer: A) beginForm()
Explanation:
beginForm() function generates the form’s opening element and returns the HTML code for it.
44. ____ in the Yii framework is the process of determining if user-submitted data fits the needed criteria before it is stored in a database or utilized for other reasons.
- Authentication
- Data Validation
- Authorization
- Ad-hoc validation
Answer: B) Data Validation
Explanation:
Data validation in the Yii framework is the process of determining if user-submitted data fits the needed criteria before it is stored in a database or utilized for other reasons.
45. ____ are the classes that really do the validation.
- Controllers
- Model
- Validators
Answer: C) Validators
Explanation:
Validators are the classes that do the validation.
46. Validation is performed on a model using which of the following function?
- Check ()
- Confirm ()
- Validation ()
- Validate()
Answer: D) Validate()
Explanation:
Validation is performed on a model using the validate() function.
47. ____ in Yii framework refers to the process of verifying data without the use of a model.
- Authentication
- Data Validation
- Authorization
- Ad-hoc validation
Answer: D) Ad-hoc validation
Explanation:
Ad-hoc validation in the Yii framework refers to the process of verifying data without the use of a model.
48. How many types of custom validators are there in the Yii framework?
- 2
- 3
- 4
- 5
Answer: A) 2
Explanation:
There are two types of custom validators: Inline and standalone.
49. ____ is a feature in the Yii framework that allows you to validate form data on the client side using JavaScript and AJAX calls without having to reload the page.
- Authentication
- Data Validation
- AJAX Validation
- Ad-hoc validation
Answer: C) AJAX Validation
Explanation:
AJAX validation is a feature in the Yii framework that allows you to validate form data on the client side using JavaScript and AJAX calls without having to reload the page.
50. In the Yii framework, a ____ is a technique of storing data that is persistent over numerous requests.
- Session
- Cookies
- Response
- Request
Answer: A) Session
Explanation:
In the Yii framework, a session is a technique for storing data that is persistent over numerous requests.
51. ____ is a transient data storage technique in the Yii framework that may be used to transfer messages or data between requests.
- Persistent storage
- Cache
- Flash data
Answer: C) Flash data
Explanation:
Flash data is a transient data storage technique in the Yii framework that may be used to transfer messages or data between requests.
52. ____ are simple text files that are kept on the client side.
- Session
- Cookies
- Response
- Request
Answer: B) Cookies
Explanation:
Cookies are simple text files that are kept on the client side.
53. In the Yii framework, a ____ is a component that supplies data for a view, such as a grid view or list view.
- Storage
- Event
- Data widget
- Data provider
Answer: D) Data provider
Explanation:
In the Yii framework, a data provider is a component that supplies data for a view, such as a grid view or list view.
54. The ____ widget receives data from a data source and displays it as a table.
- ListView
- GridView
- TemplateView
Answer: B) GridView
Explanation:
The GridView widget receives data from a data source and displays it as a table.
55. A ____ is an entity that knows how to create and configure objects.
- Dependency injection
- Database access object
- Data widget
Answer: A) Dependency injection
Explanation:
A DI container (dependency injection) is an entity that knows how to create and configure objects.
56. What is DAO in Yii?
- Data access oriented
- Data active object
- Data access object
Answer: C) Data access object
Explanation:
DOA stands for data access object.
57. Which of the following databases does DOA supports?
- MySQL
- MSSQL
- SQLite
- MariaDB
- All of the above
Answer: E) All of the above
Explanation:
Following databases are supported by DOA:
- MySQL
- MSSQL
- SQLite
- MariaDB
- PostgreSQL
- ORACLE
- CUBRID
58. Yii ____ allows you to add more functionality to an object without changing its code.
- Activity
- Behaviours
- Active data
Answer: B) Behaviours
Explanation:
Yii behaviors allow you to add more functionality to an object without changing its code.
59. Which of the following lets you generate SQL queries programmatically?
- DOA
- Query Composer
- Query Generator
- Query builder
Answer: D) Query builder
Explanation:
The query builder lets you generate SQL queries programmatically.
60. Which NoSQL DB does the Active record class support?
- Redis
- Mongo
- Both
- Only A
- Only B
Answer: C) Both
Explanation:
Active record class support following NoSQL DB:
- Redis
- Mongo
61. Which of the following are the main component of DOA?
- Data provider
- Query
- Active record
- Command
- All of the above
Answer: E) All of the above
Explanation:
Following are the main component of DOA:
- Data provider
- Query
- Active record
- Command
62. Which of the following API Clears the cache of all data values?
- Delete()
- Del()
- Flush()
Answer: C) Flush()
Explanation:
Flush () clears the cache of all data values.
63. An alias begins with the ____ symbol.
- ~
- @
- $
- _
Answer: B) @
Explanation:
An alias begins with the @ symbol.
64. Does the Yii framework has a built-in error-handling feature?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, the Yii framework has a built-in error-handling feature.
65. ____ refers to the process of validating a user’s identity.
- Localization
- Globalization
- Authorisation
- Authentication
Answer: D) Authentication
Explanation:
Authentication refers to the process of validating a user’s identity.
66. What is ACF in the Yii framework?
- Active control feature
- Access control filter
- Active control filter
Answer: B) Access control filter
Explanation:
ACF stands for access control filter
67. The process of determining whether a user has sufficient authority to accomplish something is known as ____.
- Localization
- Globalization
- Authorisation
- Authentication
Answer: C) Authorisation
Explanation:
The process of determining whether a user has sufficient authority to accomplish something is known as authorization.