Java Reference
In-Depth Information
In object oriented programming, we wrap methods and variables inside another program-
ming element which is known as a class. In object oriented programming the class concept is
the killer concept and many object oriented concepts are built around classes. We will learn
some of them here.
The first question which can arise is why there is a need to define classes. In procedural lan-
guages, all programming code is saved inside methods and you can build the entire software
product by creating various methods to do various required computations. From this point
of view, classes look superficial and redundant.
Let us think about classes from another angle. One of the primary requirements when build-
ing a software product is to make it platform independent. The entire product can be run on
just any operating system once the product has been made. For this to happen the program-
ming language should provide a rich and complete environment where the programmers do
not have to worry about the operating system. This means the people who developed the pro-
gramming language should provide all necessary infrastructure on which programmers can
build their own product. This infrastructure comes in the form of extensive libraries which
programmers can use in their source code.
When a programmer writes his/her source code then he/she can use the infrastructure
provided by operating systems. They have this infrastructure available through operating
system's API (Application Programming Interface). For example if the programmer needs to
create a user screen then he/she can use operating system's API. But in this case, the source
code written by the programmer will run only on this operating system and will not run on
any other operating system. If the programmer has to make his/her source code run on some
other operating system then he/she will have to write his/her source code separately for all
operating systems on which the software product needs to run.
To facilitate programmer's work in writing source code which can run on all platforms, the
people who develop programming languages provide their own libraries which a program-
mer can use. In such cases, the programmer will not use operating system's API and in-
stead will use programming language libraries. For example, Java language has libraries like
Java.awt.* which take care of infrastructure required for building user interfaces. When this
library is available to the programmer then he/she does not has to rely on APIs provided by
operating systems. They will be using these libraries and then their code will run on all plat-
forms and so their software product will be truly platform independent.
Search WWH ::

Custom Search