If you refer to Figure 1.3 and 1.4, scope of variables will become much more clear to you.
Procedural programming languages have limited space to define variables. Variables are
contained inside methods and thus both public and private variables have to be declared in-
side methods for doing various kinds of computations. When variables need to be accessed
from outside the method then they are declared public. Otherwise when variables need to
be accessed from inside the method then they are declared private.
In contrast object oriented programming languages provide more flexibility as they have
more space for defining variables. Variables can be defined inside methods or they can also
be defined at class level. If any variable needs to be accessed from outside the class then
they need to be declared public. Thus there is no need for any variable to be declared public
inside methods. We will be learning more about scope of variables when we learn methods
and classes later in the chapter.