Angular MCQs – Forms in Angular

11.) Which directive disables a form control?

A) disableControl
B) disable
C) [disabled]
D) formControl.disable()

Answer: Option C

Explanation: The [disabled] property disables form fields in the template.

12.) What is the use of patchValue() in Reactive forms?

A) Updates all form controls
B) Updates specific form controls
C) Clears all form controls
D) Deletes form controls

Answer: Option B

Explanation: patchValue() updates only specific controls, while setValue() updates all controls.

13.) What is the default value of pristine in a new form?

A) true
B) false
C) undefined
D) null

Answer: Option A

Explanation: A form is pristine (true) until the user modifies it.

14.) How can you reset a form in Angular?

A) form.update()
B) form.clear()
C) form.value = null
D) form.reset()

Answer: Option D

Explanation: reset() clears form values and resets validation.

15.) How do you get the value of a form control in Reactive forms?

A) formControl.value
B) formControl.getValue()
C) formControl.fetch()
D) formControl.returnValue()

Answer: Option A

Explanation: .value gives the current value of the form control.

16.) What is the default value of status in a newly created form?

A) VALID
B) INVALID
C) PENDING
D) NULL

Answer: Option B

Explanation: A form is INVALID by default until all required fields are filled and validation rules are met.

17.) What does touched mean in Angular forms?

A) The form has been submitted
B) The field has been modified
C) The user has clicked inside the field
D) The field is empty

Answer: Option C

Explanation: .touched becomes true once the user focuses and then leaves the field.

18.) Which of the following is true about dirty in Angular forms?

A) It becomes true when the form is modified
B) It is always false
C) It checks if the form is valid
D) It resets the form

Answer: Option A

Explanation: A form field is dirty (true) if the user has changed its value.

19.) How do you dynamically add form controls in a Reactive form?

A) Using form.addControl()
B) Using FormArray.push()
C) Using form.insertControl()
D) Using form.extend()

Answer: Option B

Explanation: FormArray.push() dynamically adds form controls to a Reactive form.

20.) What does updateValueAndValidity() do in Angular forms?

A) Clears all form errors
B) Resets the form to its default state
C) Updates the form value and revalidates it
D) Disables all validations

Answer: Option C

Explanation: This method is used when form controls change dynamically, and validation needs to be rechecked.

Leave a Reply

Your email address will not be published. Required fields are marked *