List two occasions when you might consider declaring variables and constants globally.

What will be an ideal response?


You might consider declaring variables and constants globally:
1. If a data item will be needed in many methods throughout a program, some programmers approve of declaring it globally. For example, if a mathematical program contains many methods that require a constant for a value such as pi, or a business program contains many methods that require a standard tax or discount rate, many programmers would allow these to be declared globally.
2.  When you learn about object-oriented programming and create a class from which you will derive objects, you can declare the class's data fields at the class level.

Computer Science & Information Technology

You might also like to view...

Illustrate how a curve’s polynomial degree and fit tolerance can be modified.

What will be an ideal response?

Computer Science & Information Technology

Context switch is the process of saving or restoring a thread's state.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

The following sentence is punctuated correctly.? The new video game is in the store, however, we cannot sell it before the release date.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

In designing a worksheet, visual aesthetics should come first.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology