Object-oriented programming (OOP) uses objects and classes to simplify software development and maintenance. The key concepts of OOP include:
1. Objects contain state and behavior, and classes define types of objects. For example, a chair object may have color and material as state, and functions like sit() as behavior.
2. Inheritance allows new classes to inherit attributes and behaviors from parent classes, promoting code reuse.
3. Encapsulation binds code and data together into a single unit and hides internal details, making classes more modular and reusable.
Object-oriented programming (OOP) uses objects and classes to simplify software development and maintenance. The key concepts of OOP include:
1. Objects contain state and behavior, and classes define types of objects. For example, a chair object may have color and material as state, and functions like sit() as behavior.
2. Inheritance allows new classes to inherit attributes and behaviors from parent classes, promoting code reuse.
3. Encapsulation binds code and data together into a single unit and hides internal details, making classes more modular and reusable.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4
OOPS CONCEPTS
Object oriented programming structure:
Object-Oriented Programming is a methodology or paradigm to design a program using classes and objects. It simplifies the software development and maintenance by providing some concepts: Object Class Inheritance Polymorphism Abstraction Encapsulation Advantage of OOPs over Procedure-oriented programming language 1)OOPs makes development and maintenance easier where as in Procedure-oriented programming language it is not easy to manage if code grows as project size grows. 2)OOPs provides data hiding whereas in Procedure-oriented prgramming language a global data can be accessed from anywhere. 3)OOPs provides ability to simulate real-world event much more effectively. We can provide the solution of real word problem if we are using the Object-Oriented Programming language.
1. Object: Software objects are conceptually similar to real-world objects: they consist of state and related behavior. Any entity that has state and behavior is known as an object. An object stores its state in fields (variables in some programming languages) and exposes its behavior through methods (functions in some programming languages). Methods operate on an object's internal state and serve as the primary mechanism for object-to-object communication. For example: chair, pen, table, keyboard, bike etc. It can be physical and logical.
2.CLASS: A class is simply a representation of a type of object. Collection of objects is called class. It is a logical entity.It is the blueprint/ plan/ template that describe the details of an object. A class is the blueprint from which the individual objects are created. Class is composed of three things: a name, attributes, and operations. 3.INHERITANCE: The ability of a new class to be created, from an existing class by extending it, is called inheritance. When one object acquires all the properties and behaviours of parent object i.e. known as inheritance. By using inheritence we can reuse the code. It provides code reusability. It is used to achieve runtime polymorphism.
4.ENCAPSULATION(INFORMATION HIDING): The class is kind of a container or capsule or a cell, which encapsulate the set of methods, attribute and properties to provide its indented functionalities to other classes. In that sense, encapsulation also allows a class to change its internal implementation without hurting the overall functioning of the system. That idea of encapsulation is to hide how a class does it but to allow requesting what to do. Binding (or wrapping) code and data together into a single unit is known as encapsulation. For example: 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.
5.ABSTRACTION: Abstraction is the process of taking away or removing characteristics from something in order to reduce it to a set of essential characteristics, programmer hides all but the relevant data about object in order to reduce complexity and increase efficiency. 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.
6.POLYMORPHISM: When one task is performed by different ways i.e. known as polymorphism. For example: to convense the customer differently, to draw something e.g. shape or rectangle etc. In java, we use method overloading and method overriding to achieve polymorphism. Another example can be to speak something e.g. cat speaks meaw, dog barks woof etc. Polymorphism means "one interface, many possible implementations." 1. Static (compile time) polymorphism 2. Dynamic (run time) polymorphism Static polymorphism means that the information required to call a function is available at compile time itself. Dynamic polymorphism means that the information required to call a function is not known until run time.