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

java unit 1

The document discusses Object Oriented Methodology (OOP) as a modern system development approach that emphasizes the use of objects and classes, facilitating software component re-use and effective system design. It contrasts OOP with structured programming, highlighting advantages such as improved code organization, data encapsulation, and the ability to model real-world scenarios. Key concepts of OOP, including inheritance, polymorphism, and abstraction, are explained along with their benefits and applications in various domains.

Uploaded by

dahiyavipin802
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)
4 views

java unit 1

The document discusses Object Oriented Methodology (OOP) as a modern system development approach that emphasizes the use of objects and classes, facilitating software component re-use and effective system design. It contrasts OOP with structured programming, highlighting advantages such as improved code organization, data encapsulation, and the ability to model real-world scenarios. Key concepts of OOP, including inheritance, polymorphism, and abstraction, are explained along with their benefits and applications in various domains.

Uploaded by

dahiyavipin802
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/ 1

Object Oriented Methodology:It is a new system development approach, Structured programming: When the program becomes larger, a single

ram becomes larger, a single list of Application of oop: The most popular application using Object Oriented
encouraging and facilitating re-use of software components.
instructions becomes unwieldy programming is the interface designing for window base systems. Real systems are
 It employs international standard Unified Modeling Language (UML) from the
A program is divided into functions or subroutines where each function has a clearly more complex and contain many objects with a large number of attributes and methods
Object Management Group (OMG).
defined purpose and a defined interface to the other functions in the program of complex nature. OOP is useful in such cases because it can simplify a complex
 Using this methodology, a system can be developed on a component basis, which
Structured programming remained the leading approach for almost two decades. problem. The application area of OOP includes:
enables the effective re-use of existing components, it facilitates the sharing of its
• Object Oriented databases
other system components.
Object oriented programming: The world is Object Oriented, and Object Oriented • Embedded systems
 Object Oriented Methodology asks the analyst to determine what the objects of the
programming expresses programs in the ways that model how people perceive the • Simulation and modeling
system are?, What responsibilities and relationships an object has to do with the
world.?? # In object oriented oriented programming, main emphasis is an data rather • Neural networks
other objects? and How they behave over time?
than functions.?? #The basic principe of object oriented oriented programming is to • Decision support systems
combine both data and functions into a single unit known as “object”.# it follow • Office automation systems
Programming paradigm:Programming paradigm is frame work that defines
bottom-up approaches.??#it deal with data??# oop is highly secure.??#it take more • AI and expert systems
how the user cocepyualized and interpets complex problems. ??#It is also a
memory than procedural language.??#In opp, overloading and data hiding is • CAD/CAM systems
fundamenteal style or approach used in software engineering to
possible.??#ex:-java,c++,etc • Internet solutions
implement a programming language.
Advantages of opp:
Differcence between programing paradigm and programming  We can build the programs from standard working modules that Concept of oop approach:The main components of Object Oriented
languages: communicate with one another, rather than having to start writing the code
from scratch which leads to saving of development time and higher technology are ‘objects and classes’, ‘data abstraction and encapsulation’,
*Programming language:it is an artificial language that has vocabulary and steps
productivity, ‘inheritance’ and ‘polymorphism’. It is very important for you to understand these
of grammatical rules to instruct a computer to perform specific tasks.  OOP language allows to break the program into the bit-sized problems that concepts.
*programming paradigm: it is a particular way of looking at a programming can be solved easily (one object at a time).
Further, in this unit you can find the details of these concepts. Objects Object
 The new technology promises greater programmer productivity, better
problem. Data + Functions
quality of software and lesser maintenance cost.
 OOP systems can be easily upgraded from small to large systems. Object: Let’s start with “Object”. The first thing that we should do in the Object
Evaloution of oo methodology: The earliest computers were  It is possible that multiple instances of objects co-exist without any Oriented approach is to start thinking in terms of Objects. The problem to be
interference,
programmed in machine language using 0 and 1. The mechanical switches were used to solved is divided into objects. Start analyzing the problem in terms of objects and
 It is very easy to partition the work in a project based on objects.
load programs. Then, to provide convenience to the programmer, assembly language the nature of communication between them. Program object should be chosen
 It is possible to map the objects in problem domain to those in the program.
 The principle of data hiding helps the programmer to build secure programs such that they match closely with real-world objects
was introduced where programmers use pneumonic for various instructions to write
which cannot be invaded by the code in other parts of the program. • Employees in a payroll system
programs.
But it was a tedious job to remember so many pneumonic codes for various • Customers and accounts in a banking system
Disadvantages of opp:
instructions. Other major problem with the assembly languages is that they are machine  The length of the programmes developed using OOP language is much • Salesman, products, customers in a sales tracking system
architecture dependent. To overcome the difficulties of Assembly language, high-level larger than the procedural approach. Since the programme becomes larger • Data structures like linked lists, stacks, etc.
languages came into existence. Programmers could write a series of English-like in size, it requires more time to be executed that leads to slower execution of
the programme. • Hardware devices like magnetic tape drive, keyboard, printer etc
instructions that a compiler or interpreter could translate into the binary language of  We can not apply OOP everywhere as it is not a universal language. It is
computers directly. applied only when it is required. It is not suitable for all types of problems. . • GUI elements like windows, menus, events, etc. in any window-based
 Programmers need to have brilliant designing skill and programming skill application.
These languages are simple in design and easy to use because programs at that time
along with proper planning because using OOP is little bit tricky.
were relatively simple tasks like any arithmetic calculations  OOPs take time to get used to it. The thought process involved in object-
oriented programming may not be natural for some people.

Classes: A class serves as a plan or template. The programmer has to specify


the entire set of data and functions for various operations on the data for an Polymoorphism: Polymorphism in Object-Oriented Programming
object as a user-defined type in the form of a class. In other words, the
Encapsulation: Encapsulation, on the other hand, protects data integrity and
promotes code security by restricting access and modification. (OOP) allows objects of different classes to respond to the same method
programmer defines the object format and behavior by defining a class. The
# To protect data integrity and prevent unauthorized access or modification by call in their own specific ways, promoting code reusability and flexibility.
compiler of that language does not know about this user-defined data type
bundling data and methods within a single unit (class). # It's achieved through mechanisms like inheritance, method overloading,
Finally, defining the class doesn’t create an object just as the existence of a built- # it achieved through access modifiers (e.g., private, protected, public) that control and method overriding, enabling a single interface to be used for various
in type integer doesn’t create any variable. Once the class has been defined, you object types.
access to class members.
can create any number of objects belonging to that class. # Polymorphism literally means "many forms," reflecting the ability of an
# Ex: In the car example, the engine's internal workings are encapsulated within
Inheritance: Inheritance is the process by which objects of one class acquire the Car class, and access to those details is controlled through methods object to take on different behaviors or implementations
the properties of objects of another class in the hierarchy. For example, the like startEngine() and accelerate() # Polymorphism is a fundamental concept in OOP, making it essential for
scooter is a type of the class two-wheelers, which is again a type of (or kind of) Uses of encapsulation: languages claiming to be object-oriented.
the class motor vehicles. As shown in the Figure 5 the principle behind it is that  Protects data from accidental or malicious modification.
the derived class shares common characteristics with the class from which it is  Types of Polymorphism:
 Improves code organization and maintainability by creating self-contained units.
derived. 1.Compile-time Polymorphism (Static): Method overloading and
 Facilitates easier collaboration and debugging by isolating the internal workings of
New classes can be built from the existing classes. It means that we can add operator overloading are examples, where the method to be called is
objects. determined at compile time.
additional features to an existing class without modifying it. The new class is
referred as derived class or sub class and the original class is known as base 2.Run-time Polymorphism (Dynamic): Method overriding is an example,
class or super class. Therefore, the concept of inheritance provides the idea of Overriding method: Method overriding, a key concept in object-oriented where the method to be called is determined at runtime based on the
reusability. This inheritance mechanism allows the programmer to reuse a class programming (OOP), allows a subclass to provide a specific implementation of a
object's actual class.
that is made almost, but not exactly, similar to the required one by adding a few method that's already defined in its superclass.
more features to it # This enables subclasses to specialize or customize the behavior inherited from
 Benefits of Polymorphism:
Abstraction: abstraction focuses on displaying only essential details and their parent class. Essentially, when a subclass defines a method with the same
name, parameters, and return type as a method in its superclass, it overrides that  Code Reusability: Reduces code redundancy by using a common
hiding complex implementation details, while encapsulation involves bundling
method. interface for different object types.
data and methods into a single unit (like a class) and controlling access to them.
# Method overriding is a way to achieve polymorphism (the ability of an object to  Flexibility: Allows programs to handle different object types seamlessly,
# Abstraction simplifies complex systems by emphasizing essential features, take on many forms). It allows different objects to have different behaviors when simplifying development and maintenance.
making them easier to understand and manage. their methods are called, even if they belong to the same class hierarchy
 Extensibility: Facilitates creating new classes derived from existing ones
# To simplify complex systems by focusing on essential details and hiding # this Method overriding is a form of run-time polymorphism, meaning the specific
without modifying the original code.
irrelevant implementation details. method that is called is determined at runtime based on the actual type of the
object, not at compile time .
#Achieved through abstract classes, interfaces, and other techniques that
#ex: Imagine a class called Animal with a method makeSound(). A subclass
expose only the necessary functionalities.
called Dog could then override this method, providing a different implementation
#Ex:Imagine a car. A driver doesn't need to know how the engine works for makeSound() that reflects a dog's bark, while Cat could override it for a meow.
internally; they just need to know how to start, accelerate, and steer
(abstraction).  Benefits of overriding method:
Uses of abstraction:  Flexibility: Subclasses can adapt the behavior of methods inherited from their
 Reduces complexity and makes code easier to understand and maintain. parent classes.

 Facilitates code reuse by allowing developers to focus on higher-level interactions  Code Reusability: Subclasses can reuse the functionality of their parent classes
without worrying about specific implementations. while adding specific customizations.

 Enhances modularity, making it easier to develop and maintain large systems.  Maintainability: Changes to the superclass implementation can be handled
through the subclass, making the code more modular and easier to maintain.

Procedural Oriented Object-Oriented


Procedural Programming vs Object-Oriented Programming Programming Programming

In procedural programming, the In object-oriented


Procedural Oriented Object-Oriented function is more important than the programming, data is more
Programming Programming data. important than function.

In object-oriented Procedural programming is based Object-oriented programming is


In procedural programming, the
programming, the program is on the unreal world. based on the real world.
program is divided into small parts
divided into small parts
called functions.
called objects.
Procedural programming is used Object-oriented programming is
for designing medium-sized used for designing large and
Object-oriented programming programs. complex programs.
Procedural programming follows
follows a bottom-up
a top-down approach.
approach.
Object-oriented programming
Procedural programming uses the
uses the concept of data
Object-oriented programming concept of procedure abstraction.
There is no access specifier in abstraction.
has access specifiers like
procedural programming.
private, public, protected, etc.
Code reusability absent in Code reusability present in
procedural programming, object-oriented programming.
Adding new data and functions is Adding new data and function
not easy. is easy.
Examples: C, FORTRAN, Pascal, Examples: C++, Java, Python,
Basic, etc. C#, etc.
Procedural programming does not Object-oriented programming
have any proper way of hiding provides data hiding so it
data so it is less secure. is more secure.

In procedural programming, Overloading is possible in


overloading is not possible. object-oriented programming.

In object-oriented
In procedural programming, there
programming, the concept of
is no concept of data hiding and
data hiding and inheritance is
inheritance.
used.

You might also like