Bird
0
0

Which of the following is the correct syntax to declare a number property age with type annotation in an Angular component?

easy📝 Syntax Q3 of 15
Angular - TypeScript in Angular
Which of the following is the correct syntax to declare a number property age with type annotation in an Angular component?
Aage: number = 30;
Bage = number 30;
Cnumber age = 30;
Dage: Number = '30';
Step-by-Step Solution
Solution:
  1. Step 1: Recall TypeScript number type syntax

    The correct syntax is propertyName: number = value; with lowercase number.
  2. Step 2: Check value type matches annotation

    Assigning 30 (a number) matches the number type.
  3. Final Answer:

    age: number = 30; -> Option A
  4. Quick Check:

    Number property syntax = age: number = 30; [OK]
Quick Trick: Use lowercase 'number' and assign numeric values directly [OK]
Common Mistakes:
  • Using uppercase Number instead of number
  • Assigning string '30' instead of number 30
  • Wrong order like 'number age = 30;'

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes