Docsity

Object-Oriented Programming: Abstract Data Types, Inheritance, and Polymorphism, Study notes of Object Oriented Programming

Toggle sidebar
bg1
OBJECT ORIENTED PROGRAMMING LANGUAGES
A language that is object oriented must provide support for three key language
features: Abstract data type, inheritance and a particular kind of dynamic binding.
Data oriented programming focuses on abstract data types. In this paradigm,
computation on data object is specified by calling sub programs associated the data
object. If any object needs to be sorted, the sorting operation is defined in abstract data
type for the array.
Languages that support data oriented programming as often called object based
languages.
Inheritance
Its nothing but software reuse. ADT with their encapsulation and access controls
were obviously the units to be reused.
• Class instance are called objects
• Class that is defined through inheritance from another class is derived
class
• Class from which new classes are derived is called parent class
• Sub programs that define operations of object are called methods
• Calls to the methods are called as messages
• Also we have single inheritance, multiple inheritance etc.
Polymorphism
• Overloading of functions, operators
• Dynamic binding
• Virtual functions
Computing with OO languages
Computing is done by
• Sending a message to an object to invoke one of its methods. A reply to a
message is an object to invoke one of its methods
pf3
pf4
pf5

Partial preview of the text

Download Object-Oriented Programming: Abstract Data Types, Inheritance, and Polymorphism and more Study notes Object Oriented Programming in PDF only on Docsity!

OBJECT ORIENTED PROGRAMMING LANGUAGES

A language that is object oriented must provide support for three key language features: Abstract data type, inheritance and a particular kind of dynamic binding. Data oriented programming focuses on abstract data types. In this paradigm, computation on data object is specified by calling sub programs associated the data object. If any object needs to be sorted, the sorting operation is defined in abstract data type for the array. Languages that support data oriented programming as often called object based languages.

Inheritance Its nothing but software reuse. ADT with their encapsulation and access controls were obviously the units to be reused.

  • Class instance are called objects
  • Class that is defined through inheritance from another class is derived class
  • Class from which new classes are derived is called parent class
  • Sub programs that define operations of object are called methods
  • Calls to the methods are called as messages
  • Also we have single inheritance, multiple inheritance etc. Polymorphism
  • Overloading of functions, operators
  • Dynamic binding
  • Virtual functions

Computing with OO languages Computing is done by

  • Sending a message to an object to invoke one of its methods. A reply to a message is an object to invoke one of its methods
  • Executing in an object oriented language can be described as a simulation of a collection of computers (objects) that communicate with each other through messages.
  • Each object is an abstraction of a computer in the sense that it stores data and provide processing capability for manipulating that data.

Small talk object oriented language A program in small talk consists entirely of objects. It means that all the items starting from integer till the file handling system are nothing but objects. They all have local memory, inherent processing ability, the capability to communicate with other object and possibility of inheriting methods and instance variables from ancestors. Small talk system integrates a program editor, compiler, the usual features of an operating system and a virtual machine into a single system.

Expressions : - four kinds

  1. (^) literals
  2. variables
  3. message expressions
  4. block expressions

Literals Numbers :- defined by class integers String :- characters are delimited by apostrophes Keyword :- training with colon.

Variables Private :- local to object Shared :- visible to all objects Named :- points to non array types Indexed :- points to array types

)4 declarations of the instance and class methods Object oriented programming in C++ It retains the type system of C and adds classes to it. This makes it a hybrid language supporting both procedural programming and object oriented programming. All C++ classes include at least one constructor method, which is used to initialize the data numbers of the new object. Constructor methods are implicitly called when an object is created. If any of the data members are heap allocated, the constructor does that allocation. Most class definition includes a destructor method which is implicitly called when an object of the class ceases to exist. C++ provides a variety of access controls. Eg – client can see the code or hidden to see the code

Inheritance in C++

  • data members – data defined inside class
  • (^) member functions
  • base class
  • derived class
  • class members can be private, public, protected
  • access mode can be private, public, protected
  • Scope resolution operator.

Dynamic binding Static binding Dynamic binding Virtual functions Pure virtual functions Abstract classes

Object oriented programming in Java

Java only values of primitive scalar types (Boolean, character and numeric types) are not objects Java has no enum C++ classes can be defined to have no parent, that is not possible in Java. All Java classes must be sub classes of the root class object. Reason is that all operations may need universality Objects are allocated with new

  • Applet an program that are interpreted by world wide web browser
  • Thread concept is there in Java
  • Final methods cannot be overridden
  • Package scope
  • Single inheritance, multiple inheritance is supported via interface