0% found this document useful (0 votes)
34 views

Introduction To Java

This document introduces object-oriented programming and Java. It discusses how OOP models real-world objects through attributes and behaviors and allows for communication between objects. Java is an object-oriented language that uses classes which contain fields and methods to represent objects. Classes can be reused and packaged to build new classes and programs, improving reliability and efficiency through code reuse.

Uploaded by

faaltu hai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

Introduction To Java

This document introduces object-oriented programming and Java. It discusses how OOP models real-world objects through attributes and behaviors and allows for communication between objects. Java is an object-oriented language that uses classes which contain fields and methods to represent objects. Classes can be reused and packaged to build new classes and programs, improving reliability and efficiency through code reuse.

Uploaded by

faaltu hai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

INTRODUCTION TO JAVA

Everywhere you look in the real world you see objects—


people, animals, plants, cars, planes, buildings,
computers and so on. Humans think in terms of objects.
Telephones, houses, traffic lights, microwave ovens and
water coolers are just a few more objects. Computer
programs, such
as the Java programs you’ll read in this book interacting software
objects.

We sometimes divide objects into two categories: animate and


inanimate. Animate objects are
―alive‖ theyinmovesomearound andsensedothings. —
Inanimate objects, on the other hand, do not move on
their own .Objects of both types, however, have some
things in common. They all have attributes (e.g., size,
shape, color and weight), and they all exhibit behaviors
(e.g., a ball rolls, bounces, inflates and deflates; a baby
cries, sleep crawls, walks and blinks; a car accelerates,
brakes and turns; a towel absorbs water). We will study
the kinds of attributes and behaviors that software
objects have. Humans learn about existing objects by
studying their attributes and observing their behaviors.
Different objects can have similar attributes and can
exhibit similar behaviors. Comparisons can be made, for
example, between babies and adults and between
humans and chimpanzees. Object-oriented design
provides a natural and intuitive way to view the software
design process—namely, modeling objects by their
attributes and behaviors just as we describe real- world
objects. OOD also models communication between
objects. Just as people send messages to one another
(e.g., a sergeant commands a soldier to stand at
attention), objects also communicate via messages. A
bank account object may receive a message to decrease
its balance by a certain amount because the customer
has withdrawn that amount of money.
Object-Oriented:

Although influenced by its predecessors, Java was not


designed to be source-code compatible with any other
language. This allowed the Java team the freedom to

KAMYA VERMA
design with a blank slate. One outcome of this was a
clean, usable, pragmatic approach to objects. Borrowing
liberally from many seminal object-software
environments of the last few decades, Java manages to
strike
a balance between the purist’s ―everything is of my
way‖ model. The object model in Java i such as integers,
are kept as high-performance non objects.

OOD encapsulates (i.e., wraps) attributes and operations (behaviors)


into objects, an object’s attributes and operations are intim information
hiding. This means that objects may know how to communicate with one
another across well-defined interfaces, but normally they are not allowed
to know how other objects are implemented ,implementation details are
hidden within the objects themselves. Wecan drive a car effectively, for
instance, without knowing the details of how engines, transmissions,
brakes and exhaust systems work internally—as long as we know how
to use the accelerator pedal, the brake pedal, the wheel and so on.
Information hiding, as we will see, is crucial to good software
engineering.

Languages like Java are object oriented. Programming in such a


language is called object-oriented programming (OOP), and it allows
computer programmers to implement an object-oriented design as a
working system. Languages like C, on the other hand, are procedural, so
programming tends to be action oriented. In C, the unit of programming
is the function. Groups of actions that perform some common task are
formed into functions, and functions are grouped to form programs. In
Java, the unit of programming is the class from which objects are
eventually instantiated (created). Java classes contain methods (which
implement operations and are similar to functions in C) as well as fields
(which implement attributes).

Java programmers concentrate on creating classes. Each class contains


fields, and the set of methods that manipulate the fields and provide
services to clients (i.e., other classes that use the class). The
programmer uses existing classes as the building blocks for constructing
new classes. Classes are to objects as blueprints are to houses. Just as

KAMYA VERMA
we can build many houses from one blueprint, we can instantiate
(create) many objects from one class.
Classes can have relationships with other classes. For example, in an
object-oriented design of a bank, the
―bank teller‖ class needs to relate ―safe‖ class, and so on. These
relationships

Packaging software as classes makes it possible for future software


systems to reuse the classes. Groups of related classes are often
packaged as reusable components. Just as realtors often say that the
three most important factors affecti location,‖ people in the software
community affecting the future of software development are ―reuse,
classes when building new classes and programs saves time and
effort.Reuse also helps

programmers build more reliable and effective systems, because


existing classes and components often have gone through extensive
testing, debugging and performance tuning.
Indeed, with object technology, you can build much of the software you
will need by combining classes, just as automobile manufacturers
combine interchangeable parts. Each new class you create will have the
potential to become a valuable software asset that you and other
programmers can use to speed and enhance the quality of future
software development efforts.

NEED FOR OOP PARADIGM:


Object-Oriented Programming:
Object-oriented programming is at the core of Java. In fact, all Java
programs are object-oriented
this isn’t an option the way that it is Therefore, this chapter begins with a
discussion of the theoretical aspects of OOP.
Two Paradigms of Programming:

KAMYA VERMA
As you know, all computer programs consist of two elements: code and
data. Furthermore,a program can be conceptually organized around its
code or around its data. That is, some programs are
writtenhappening‖aroundand―whatothersis are wri affected.‖ These are
the two paradigms that g
The first way is called the process-oriented model. This approach
characterizes a program as a series of linear steps (that is, code). The
process-oriented model can be thought of as code acting on data.
Procedural languages such as C employ this model to considerable
success. Problems with this approach appear as programs grow larger
and more complex. To manage increasing complexity, the second
approach, called object-oriented programming, was conceived.

Object-oriented programming organizes a program around its data (that


is, objects) and a set of well-defined interfaces to that data. An object-
oriented program can be characterized as data controlling access to
code. As you will see, by switching the controlling entity to data, you can
achieve several organizational benefits.
Procedure oriented Programming:
In this approach, the problem is always considered as a sequence of
tasks to be done. A number of functions are written to accomplish these
attention on data.

There are many high level languages like COBOL, FORTRAN, PASCAL,
C used for conventional programming commonly known as POP.

POP basically consists of writing a list of instructions for the computer to


follow, and organizing these instructions into groups known as functions.

KAMYA VERMA

You might also like