Give an example of how a static variable can be used in a class.

What will be an ideal response?


Suppose that a program needs to keep track of how many objects of a particular class have been created.
Declaring and managing a counter at the program level could be a complex task. It might be simpler to let the class itself
maintain the counter. A static int variable could be declared at the class level to be used as a counter. All of the constructors of
the class could increment the static variable. A static method would also be needed to return the value of the counter.

Computer Science & Information Technology

You might also like to view...

Which function returns a value at the intersection of a specified row and column?

A) MATCH B) VLOOKUP C) INDEX D) IF

Computer Science & Information Technology

You use the methods and properties of the ____ object to control the Web browser window.

A. Navigator B. Screen C. Document D. Window

Computer Science & Information Technology

____ hardening involves the use of routers, firewalls, IDS systems, and fault tolerance to help provide a protected and highly-available network.

A. Network B. System C. Application D. Operating system

Computer Science & Information Technology

To create a chart in Excel, select the ___________ for the chart.

a. category labels b. range c. location d. type

Computer Science & Information Technology