✏️ Explanatory Question

What are static fields in X++?

👁 2 Views
📘 Detailed Answer
🟢 Easy
2
Total Views
10
Related Qs
0%
Progress
💡

Answer with Explanation

Static fields are variables declared using the static keyword. They belong to the class rather than to individual objects.

Example:

 
private static int counter;

Characteristics:

  • Only one copy exists per session.

  • Shared across all objects of the class.

  • Used for shared state or configuration data.

Static fields are useful when you need:

  • Global counters

  • Shared configuration values

  • Singleton instance storage

They reduce duplication and enforce centralized data management.