Vous êtes sur la page 1sur 7

Object Oriented Programming IN JAVA

OOP IN JAVA

Matei Gabriela

Contents
1. 2. 3. Introduction..3 The Java Programming Language..4 Java is object-oriented5

OOP IN JAVA

Matei Gabriela

1. Introduction

Computers are used for solving problems quickly and accurately irrespective of the magnitude of the input. To solve a problem, a sequence of instructions is communicated to the computer. To communicate this instructions, programming languages are developed. The instructions written in a programming language comprise a program. A group of programs developed for certain specific purposes are reffered to as software whereas the electronic component of a computer are refered to as hardware. Computer hardware can understand instructions only in the form of machine codes i.e. 0s and 1s. A programming language used to communicate with the hardware of a computer is known as low-level language or machine language. It is very difficult for humans to understand machine language programs because the instructions contain a sequence of 0s and 1s only and, also, it is difficult to identify errors in machine language programs. To overcome the difficulties of machine languages, high-level languages such as Basic, Fortran, Pascal, COBOL and C were developed. High-level languages allow some English-like words and mathematical expressions that facilitate better understanding of the logic involved in program. While solving complex problems, a lot of difficulties were faced in the algorithmic ( step-by-step instructions to solve a problem ) approach. Hence, object-oriented programming language such as C++ and Java were evolved with a different approach to solve the problems. Object-oriented languages are also high-level languages with concepts of classes and objects.

OOP IN JAVA

Matei Gabriela

2. The Java Programming Language


The Java programming Language is ideal for developing secure, distributed, network-based end-user aplications in environments ranging from network-embedded to the World-Wide Web and the desktop. Primary characteristics of the Java programming Language include a simple language that can be programmed without extensive programmer training while being attuned to current software practices. The Java programming language is designed to be object oriented from the ground up. Even though C++ was rejected as an implementation language, keeping the Java programming language looking like C++ as far as possible results in it being a familiar language, while removing the unnecessary complexities of C++. Having the Java programming language retain many of the object-oriented features and the "look and feel" of C++ means that programmers can migrate easily to the Java platform and be productive quickly.

OOP IN JAVA

Matei Gabriela

4.

Java is Object Oriented

From all the characteristics of the Java programming language presented above ( i.e. simple , secure etc ) the object oriented buzzword will be more detailed. Object Oriented programming concepts As an object-oriented language, Java draws on the best concepts and features of previous object-oriented languages, primarily Eiffel, SmallTalk, Objective C, and C++. Java goes beyond C++ in both extending the object model and removing the major complexities of C++. With the exception of its primitive data types, everything in Java is an object, and even the primitive types can be encapsulated within objects if the need arises.

OOP IN JAVA

Matei Gabriela

Object-oriented programming is a method of programming based on a hierarchy of classes


and well-defined and cooperating objects. An object is a software bundle of related state and behavior.Objects in programming language have certain behavior, properties, type, and identity. In OOP based language the principal aim is to find out the objects to manipulate and their relation between each other. OOP offers greater flexibility and compatibility and is popular in developing larger application. Another important work in OOP is to classify objects into different types according to their properties and behavior. So OOP based software application development includes the analysis of the problem, preparing a solution, coding and finally its maintenance.

Java is a object oriented programming and to understand the functionality of OOP in Java, we
first need to understand several fundamentals related to objects. These include class, method, inheritance, encapsulation, abstraction, polymorphism etc.

Classes
A class is a structure that defines the data and the methods to work on that data. When you write programs in the Java language, all program data is wrapped in a class, whether it is a class you write or a class you use from the Java platform API libraries. It is the central point of OOP and that contains data and codes with behavior. In Java everything happens within class and it describes a set of objects with common behavior. The class definition describes all the properties, behavior, and identity of objects present within that class. As far as types of classes are concerned, there are predefined classes in languages like C++ and Pascal. But in Java one can define his/her own types with data and code. Example : The Program class is a programmer-written class that uses the java.lang.System class from the Java platform API libraries to print a character string to the command line. classProgram { public static void main(String[] args){ System.out.println("I'm a Program"); }
6

OOP IN JAVA

Matei Gabriela

} The java.lang.System class used in the example defines such things as standard input, output, and error streams, and access to system properties. In contrast, the java.lang.String class defines character strings

Objects
Objects are the basic unit of object orientation with behavior, identity. As I mentioned above, these are part of a class but are not the same. An object is expressed by the variable and methods within the objects. Again these variables and methods are distinguished from each other as instant variables, instant methods and class variable and class methods.

Methods
We know that a class can define both attributes and behaviors. Again attributes are defined by variables and behaviors are represented by methods. In other words, methods define the abilities of an object.

Inheritance
This is the mechanism of organizing and structuring software program. Though objects are distinguished from each other by some additional features but there are objects that share certain things common. In object oriented programming classes can inherit some common behavior and state from others. Inheritance in OOP allows to define a general class and later to organize some other classes simply adding some details with the old class definition. This saves work as the special class inherits all the properties of the old general class and as a programmer you only require the new features. This helps in a better data analysis, accurate coding and reduces development time. In the Java programming language, all classes descend from java.lang.Object and implement its methods.

Vous aimerez peut-être aussi