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

Updated:

Published an Android mobile application which contains interview questions, Angular official tweets, blogs, Angular Gitter channel, GitHub release notes. Cheers!

Updated: Answers added.

Along with my freelancing work routine, I do conduct technical interviews and corporate training for Angular. During course of time, I have piled up good amount of interview questions. I will be listing questions in sets of 20.

I am still not sure whether to provide answers or leave it to readers. For now leaving it to readers for some brain exercise. Based on response, I shall add answers to set. These questions contains Angular and Typescript concepts.

I will create an online quiz as well soon enough.

  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

Do you want to continue teasing your brain?

Here are the other sets.

Cloud Solution Architect | Author | Full Stack Developer | https://www.linkedin.com/in/balram-chavan | https://www.hiretheauthor.com/balramchavan

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store