Computer Knowledge
GUI and Web Frameworks
1,915 Questions
Graphical user interface and web frameworks involve layout management, directives, and application design across platforms like Android and Angular. These concepts are tested in computer science and IT officer competitive exams. Review these questions to understand UI components and coding standards.
Android layout attributesAngular structural directivesVB.Net web methodsJava Swing componentsSiebel application framework
GUI and Web Frameworks Questions
Which of the following is NOT a type of data binding in Angular?
-
Interpolation
-
Property Binding
-
Event Binding
-
Structural Binding
D
Correct answer
Explanation
Structural Binding is not a type of data binding in Angular. The three main types of data binding in Angular are Interpolation, Property Binding, and Event Binding.
What is the purpose of property binding in Angular?
-
To set the value of a DOM element's property based on a component property.
-
To listen for events on a DOM element and respond to them.
-
To conditionally include or exclude DOM elements from the template.
-
To repeat a block of HTML for a collection of data.
A
Correct answer
Explanation
Property binding in Angular allows you to set the value of a DOM element's property based on the value of a component property. This enables you to dynamically update the DOM based on changes to the component's properties.
What is the syntax for property binding in Angular?
-
{{ property }}
-
[(property)]
-
(property)
-
[property]
D
Correct answer
Explanation
Property binding in Angular is denoted by square brackets []. It allows you to bind a component property to a DOM element's property, enabling you to dynamically update the DOM based on changes to the component's properties.
What is the purpose of event binding in Angular?
-
To set the value of a DOM element's property based on a component property.
-
To listen for events on a DOM element and respond to them.
-
To conditionally include or exclude DOM elements from the template.
-
To repeat a block of HTML for a collection of data.
B
Correct answer
Explanation
Event binding in Angular allows you to listen for events on a DOM element and respond to them by executing a method in your component. This enables you to handle user interactions with the DOM.
What is the syntax for event binding in Angular?
-
{{ property }}
-
[(property)]
-
(property)
-
[property]
C
Correct answer
Explanation
Event binding in Angular is denoted by parentheses (). It allows you to bind a DOM event to a method in your component, enabling you to handle user interactions with the DOM.
What is a structural directive in Angular?
-
A directive that adds or removes DOM elements from the template based on a condition.
-
A directive that modifies the behavior of a DOM element.
-
A directive that listens for events on a DOM element.
-
A directive that binds a component property to a DOM element's property.
A
Correct answer
Explanation
Structural directives in Angular are directives that can add, remove, or manipulate DOM elements based on a condition. They are used to conditionally include or exclude DOM elements from the template.
What is an example of a structural directive in Angular?
-
ngIf
-
ngFor
-
ngSwitch
-
ngClass
A
Correct answer
Explanation
ngIf is an example of a structural directive in Angular. It allows you to conditionally include or exclude a DOM element from the template based on a condition.
What is an attribute directive in Angular?
-
A directive that adds or removes DOM elements from the template based on a condition.
-
A directive that modifies the behavior of a DOM element.
-
A directive that listens for events on a DOM element.
-
A directive that binds a component property to a DOM element's property.
B
Correct answer
Explanation
Attribute directives in Angular are directives that can modify the behavior of a DOM element. They are used to add additional functionality to DOM elements.
What is an example of an attribute directive in Angular?
-
ngIf
-
ngFor
-
ngSwitch
-
ngClass
D
Correct answer
Explanation
ngClass is an example of an attribute directive in Angular. It allows you to dynamically add and remove CSS classes to a DOM element based on a condition.
What is the purpose of the *ngFor directive in Angular?
-
To conditionally include or exclude DOM elements from the template.
-
To repeat a block of HTML for a collection of data.
-
To modify the behavior of a DOM element.
-
To listen for events on a DOM element.
B
Correct answer
Explanation
The *ngFor directive in Angular is used to repeat a block of HTML for a collection of data. It allows you to easily iterate over an array or object and display its elements in the template.
What is the syntax for the *ngFor directive in Angular?
-
*ngFor="let item of items"
-
*ngFor="item of items"
-
*ngFor="items"
-
*ngFor="let item in items | async"
A
Correct answer
Explanation
The syntax for the *ngFor directive in Angular is *ngFor="let item of items". It allows you to specify the collection of data to iterate over and the variable to use for each item in the collection.
What is the purpose of the ngSwitch directive in Angular?
-
To conditionally include or exclude DOM elements from the template.
-
To repeat a block of HTML for a collection of data.
-
To modify the behavior of a DOM element.
-
To listen for events on a DOM element.
A
Correct answer
Explanation
The ngSwitch directive in Angular is used to conditionally include or exclude DOM elements from the template based on a value. It allows you to display different content depending on the value of a property.
What is the syntax for the ngSwitch directive in Angular?
-
[ngSwitch]="value"
-
(ngSwitch)="value"
-
*ngSwitch="value"
-
ngSwitch="value"
A
Correct answer
Explanation
The syntax for the ngSwitch directive in Angular is [ngSwitch]="value". It allows you to specify the value to switch on and the different cases to handle.
Which of the following is NOT a common type of user interface (UI) element?
-
Buttons.
-
Menus.
-
Icons.
-
Data analytics.
D
Correct answer
Explanation
Data analytics is not a type of UI element, as it involves analyzing data to understand user behavior and patterns, rather than being a visual element that users interact with.
What is the providedIn property used for in Angular services?
-
To specify the scope of the service (root or component)
-
To define the dependencies required by the service
-
To provide metadata about the service for DI
-
To configure the lifecycle hooks of the service
A
Correct answer
Explanation
The providedIn property in Angular services determines the scope of the service, whether it's available throughout the application (root) or only within a specific component (component).