FAQ:

FAQ

  •  Explain the data encapsulation principle?  
- An object's data should be accessible only to the object
- Becking fields containing the object data should be marked as private.
  • What is a backing field?
- A variable in a class used to retain each object's data

  • When should you use a backing field? 
- For every data field retained for an object 

  • When should you use a constant? 
- When defining a field with a simple data type that that will never change.
  • When should you use a read-only field?
 - When defining a field that is initialized from a file, table, or code, but should not change anywhere else in the application.

  • What is the difference between a constant and a read-only field? 
-  A constant
  • Is static
  • Assigned on the declaration
  • Assigned to an expression that is fully evaluated at compile time.
  
- A Read-only field 
  • can be static or non-static
  • Assigned in the declaration or in a constructor
  • Assigned to any type of valid expression 

Comments

Popular posts from this blog

Constant vs Read-Only

Constants