Bird
0
0

How do you correctly declare an interface named Order with a numeric orderId and a string customerName in Angular?

easy📝 Syntax Q3 of 15
Angular - TypeScript in Angular
How do you correctly declare an interface named Order with a numeric orderId and a string customerName in Angular?
Ainterface Order (orderId: number, customerName: string);
Binterface Order = { orderId: number; customerName: string; }
Cinterface Order { orderId: number; customerName: string; }
Dinterface Order { orderId = number; customerName = string; }
Step-by-Step Solution
Solution:
  1. Step 1: Recall interface syntax

    Interfaces use the interface Name { property: type; } syntax.
  2. Step 2: Identify correct declaration

    interface Order { orderId: number; customerName: string; } correctly declares properties with their types inside curly braces.
  3. Final Answer:

    interface Order { orderId: number; customerName: string; } -> Option C
  4. Quick Check:

    Options B, C, and D use invalid syntax for interfaces. [OK]
Quick Trick: Use colon to assign types inside interface braces [OK]
Common Mistakes:
  • Using equals sign instead of colon for types
  • Trying to assign values inside interface
  • Using parentheses instead of braces

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Angular Quizzes