InterviewSolution
| 1. |
What Is The Static Field Modifier? |
|
Answer» Class member VARIABLES are OFTEN called INSTANCE variables because each instance of the class, each object, gets its own copy of each variables. Depending on your program's purpose, there may be times when the class objects NEED to share information. In such cases, you can specify one or more class variables as shared among the objects. To share a variable among class objects, you declare the variable as static, as shown: PUBLIC static int ShareThisValue; In this case, if object changes the value of the ShareThisValue variables, each object will see the updated value. Class member variables are often called instance variables because each instance of the class, each object, gets its own copy of each variables. Depending on your program's purpose, there may be times when the class objects need to share information. In such cases, you can specify one or more class variables as shared among the objects. To share a variable among class objects, you declare the variable as static, as shown: public static int ShareThisValue; In this case, if object changes the value of the ShareThisValue variables, each object will see the updated value. |
|