OOP: Introduction. 4. The Class Concept. • A class is a collection of objects (or values) and a corresponding set of methods. • A class encapsulates the data. Object-Oriented Programming (OOP) uses "objects" to model realworld objects. Object- Programming (OOP) consist of some important concepts namely. 5 days ago Learn concept of Object Oriented Programming(OOP) in java with example. Inheritance is an OOPS concept in which one object acquires the properties and behaviors of the parent . JavaScript Tutorial for Beginners PDF.

Oop Concept Pdf

Language:English, French, Portuguese
Published (Last):02.02.2016
ePub File Size:30.60 MB
PDF File Size:8.51 MB
Distribution:Free* [*Registration Required]
Uploaded by: CHANTELLE

Software crisis. Software Evaluation. POP (Procedure Oriented Programming). OOP (Object Oriented Programming). Basic concepts of OOP. OOP Concepts. Object Oriented Programming, OOP, is the must influential paradigm of our time. This handout summarizes the most basic style, elements, and. 8. General Concept of OOP. Introduction. The object-oriented programming ( OOP) is a different approach to programming. Object oriented technology.

An object contains an address and takes up some space in memory. Objects can communicate without knowing the details of each other's data or code.

Java OOPs Concepts

The only necessary thing is the type of message accepted and the type of response returned by the objects. Example: A dog is an object because it has states like color, name, breed, etc. Class Collection of objects is called class.

It is a logical entity.

A class can also be defined as a blueprint from which you can create an individual object. Class doesn't consume any space. Inheritance When one object acquires all the properties and behaviors of a parent object, it is known as inheritance. It provides code reusability. It is used to achieve runtime polymorphism. Polymorphism If one task is performed in different ways, it is known as polymorphism.

For example: to convince the customer differently, to draw something, for example, shape, triangle, rectangle, etc. In Java, we use method overloading and method overriding to achieve polymorphism. Another example can be to speak something; for example, a cat speaks meow, dog barks woof, etc. Abstraction Hiding internal details and showing functionality is known as abstraction.

For example phone call, we don't know the internal processing. In Java, we use abstract class and interface to achieve abstraction.

Advantages of OOPS:

Encapsulation Binding or wrapping code and data together into a single unit are known as encapsulation. For example, a capsule, it is wrapped with different medicines. A java class is the example of encapsulation.

Java bean is the fully encapsulated class because all the data members are private here. Coupling Coupling refers to the knowledge or information or dependency of another class. It arises when classes are aware of each other. If a class has the details information of another class, there is strong coupling. In Java, we use private, protected, and public modifiers to display the visibility level of a class, method, and field.

You can use interfaces for the weaker coupling because there is no concrete implementation. Cohesion Cohesion refers to the level of a component which performs a single well-defined task.

A single well-defined task is done by a highly cohesive method. The weakly cohesive method will split the task into separate parts. The java. However, the java. Association Association represents the relationship between the objects. Here, one object can be associated with one object or many objects.

There can be four types of association between the objects: One to One Many to One, and Many to Many Let's understand the relationship with real-time examples.

Object Oriented Programming

For example, One country can have one prime minister one to one , and a prime minister can have many ministers one to many. Also, many MP's can have one prime minister many to one , and many ministers can have many departments many to many. Association can be undirectional or bidirectional. Aggregation Aggregation is a way to achieve Association. Abstraction focuses on the outside view of an object i. The attributes are sometimes called data members because they hold information. The functions that operate on these data are sometimes called methods or member function.

Computer scientists use abstraction to understand and solve problems and communicate their solutions with the computer in some particular computer language. This allows you to reduce a complex operation into a generalization that retains the base characteristics of the operation.

For example, an abstract interface can be a well-known definition that supports data access operations using simple methods such as Get and Update. Another form of abstraction could be metadata used to provide a mapping between two formats that hold structured data.

Abstraction is something we do every day e. We abstract the properties of the object, and keep only what we need E. The implementation issues are deferred to a later time or are provided by somebody else e. As a result, we only have to focus on one aspect at a time. This issue is usually referred to as separation of concerns. Since we define these new high-level types from an abstract point of view, they may be called abstract types. An abstract type denotes a set of entities characterized by a list of operations that may be applied to them together with a precise specification of each one of these operations.

Usually, the list of operations that define a type and their specification are referred to as the type behaviour, type specification or the type contract. An abstract type is also called interface. The set of entities which share the operations defined for a type are called instances of that type.

An example of abstract type may be the type Student. This is an abstract type whose instances are each one of the specific students Joe, Ann Usually, we will refer to abstract types just as types.

This approach is coincident to what we do in everyday life to manage complexity. For instance, cars are very complicated machines.

In fact, it would be very difficult, if not impossible, to drive having in mind, at the same time, the functionality expected from the car the what: speed up, change direction, brake, etc. Encapsulation Objects expose functionality only through methods, properties, and events, and hide the internal details such as state and variables from other objects.

This is wrapping up of data and functions into a single unit called class. Data encapsulation is the most striking feature of a class. The data is not accessible to the outside world, and only those functions which are wrapped in the class can access it.

This insulation of the data from direct access by the program is called data hiding or information hiding. Therefore encapsulation means putting the data and the function that operates on that data in a single unit information hiding.

It is the mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse. Eg:-automatic transmission of an automobile.

It encapsulates lots of information about the engine, such acceleration, the pitch of the surface, and the position of the shift lever. Being a user, we have only one method of affecting this complex encapsulation: moving the gear-shift lever.

Polymorphism, a Greek term, means the ability to take more than one form. For example, consider the operation of addition.

For two numbers, the operation will generate a sum. If the operands are strings, then the operation would produce a third string by concatenation. The process of making an operator to exhibit different behaviors in different instances is known as operator overloading. This is something similar to a particular word having several different meanings depending upon the context. Using a single function name to perform different type of task is known as function overloading.

Polymorphism plays an important role in allowing objects having different internal structures to share the same external interface. This means that a general class of operations may be accessed in the same manner even though specific action associated with each operation may differ. Polymorphism is extensively used in implementing inheritance.

Pdf of oops concept

There are several different kinds of polymorphism. For example, a variable named USERID may be capable of being either an integer whole number or a string of characters perhaps because the programmer wants to allow a user to enter a user ID as either an employee number - an integer - or with a name - a string of characters.

By giving the program a way to distinguish which form is being handled in each case, either kind can be recognized and handled. For example, if given a variable that is an integer, the function chosen would be to seek a match against a list of employee numbers; if the variable were a string, it would seek a match against a list of names. In either case, both functions would be known in the program by the same name. This type of polymorphism is sometimes known as overloading.

A given operator can also be given yet another meaning when combined with another operator. The meaning of a particular operator is defined as part of a class definition.That is both data and function that operate on data are bundled as a unit called as object. The meaning of a particular operator is defined as part of a class definition.

Think about how you use your phone: Cell phones are complex. In other words we may have common features or characteristics that may be needed by number of classes.

The implementation issues are deferred to a later time or are provided by somebody else e. Object Oriented Programming is a programming concept that works on the principle that objects are the most important part of your program.

The class that is inherited from is called the superclass. For example, if a function simply determines the length of a list, it doesn't matter what data types are in the list.