Sunday 9 September 2018

Angular 2, 4,5 and 6 interview questions — Set 1

Angular 2, 4,5 and 6 interview questions — Set 1

Updated: Answers added.

  1. What will be the output of below program?
a. Undefined
b. 101
c. Compilation error for a
d. Compilation error for b
2. What is name of a special function of class which gets called when object is created and it’s syntax in Typescript?
3. What are the basic rules of Decorators?
4. If you do not know the number of arguments to be passed to function in advance, you should use _______ parameter type.
5. _____ keyword is used to access class’s member variables and functions inside class member function.
6. In Angular, you can pass data from parent component to child component using
a. @Output()
b. @Input()
c. Input
d. Output
7. In Angular, you can pass data from child component to parent component using
a. @Output()
b. @Input()
c. Input
d. Output
8. Write a syntax for ngFor with <li> example.
9. We must import ____________ module to use [(ngModel)].
10. Import ____________ module to use reactive form.
11. Write an example to define custom event with Boolean argument with code and passing data to parent component.
12. Write a syntax to bind custom CSS class (e.g. highlighted) to a <div> tag.
13. You can create local HTML reference of HTML tag using variable which starts with character
a. @
b. #
c. *
d. &
14. You can access HTML local reference alias in component’s typescript code using ___________ decorator.
15. In template driven form _________ object is created internally whenever we have below code
<form #heroForm=”ngForm”>
whereas in reactive form, we have to create this object explicitly.
16. Choose correct form control class name which is set to true when value is modified
a. .ng-valid
b. .ng-invalid
c. .ng-pending
d. .ng-pristine
e. .ng-dirty
f. .ng-untouched
g. .ng-touched
17. If you provide a service in two components’ “providers” section of @Component decorator, how many instances of service shall get created?
a. 1
b. 2
c. 3
d. 4
18. When you apply ‘pipe’, it changes value of underlying component’s member variable as well.
a. True
b. False
19. In routing, below tag is used to show selected route component dynamically
a. <router></router>
b. <router-output></router-output>
c. <router-outlet></router-outlet>
d. <router-input></router-input>
20. We need to call below method of RouterModule for providing all routes in AppModule
a. RouterModule.forChild
b. RouterModule.forRoot
c. RouterModule
d. RouterModule.all

Answers:

  1. (d)
  2. constructor — constructor(){}
  3. a function which has annotation of @() with optional parameters
  4. Rest parameter
  5. this
6. b
7. a
8. <li *ngFor=”let item of allItems”>
{{item}}
</li>
9. FormsModule
10. ReactiveFormsModule
11. objEvent = new EventEmitter<boolean>();
12. <div [class]=”myclass”]
13. b
14. @ViewChild()
15. FormGroup
16. e
17. b
18. b
19. c
20. b

No comments:

Post a Comment

40 Latest Interview Questions and Answers on Spring, Spring MVC, and Spring Boot

  40 Latest Interview Questions and Answers on Spring, Spring MVC, and Spring Boot 1. What is Tight Coupling? When a class (ClassA) is depen...