Loading

Quipoin Menu

Learn • Practice • Grow

angular / Angular Directives
mcq
Direction: Choose the correct option

Q1.

What are directives in Angular?
A. CSS styles
B. Classes that add behavior to DOM elements
C. HTML templates
D. Services
Direction: Choose the correct option

Q2.

What are the three types of directives in Angular?
A. Pipes, filters, directives
B. Modules, components, templates
C. Components, structural, attribute
D. Components, services, pipes
Direction: Choose the correct option

Q3.

Which directive is used to conditionally add or remove an element?
A. ngStyle
B. ngClass
C. *ngIf
D. ngFor
Direction: Choose the correct option

Q4.

What is an attribute directive?
A. A directive for routing
B. A directive that adds or removes elements
C. A directive that creates components
D. A directive that changes appearance or behavior of an element
Direction: Choose the correct option

Q5.

What does the asterisk (*) before structural directives indicate?
A. It indicates a built-in directive
B. It marks a directive as structural
C. It's required for all directives
D. It's syntactic sugar for `<ng-template>`
Direction: Choose the correct option

Q6.

Which of the following is a built-in attribute directive?
A. ngStyle
B. All of the above
C. ngClass
D. ngModel
Direction: Choose the correct option

Q7.

What is the purpose of `ngNonBindable` directive?
A. To create non-bindable elements
B. To disable bindings
C. To prevent compilation
D. To tell Angular not to evaluate bindings in a section
Direction: Choose the correct option

Q8.

Can you create custom directives?
A. Only attribute directives
B. Only structural directives
C. Yes, by creating a class with @Directive decorator
D. No, only built-in
Direction: Choose the correct option

Q9.

What is the difference between a component and a directive?
A. Directives are components
B. They are the same
C. A component has a template, a directive does not
D. Components are directives
Direction: Choose the correct option

Q10.

How do you apply multiple structural directives to one element?
A. Use `*ngIf; else`
B. You cannot; use `<ng-container>` to wrap them
C. Use multiple asterisks
D. Separate with commas