Answer Posted / rakesh satpute
Characteristics of Object Oriented Languages
Objects:
Objects are the basic run-time entities in an object
oriented system.They may represent a person,a place or any
item that the program has to handle.
They may also represent user defined data such as
vectors,time and lists.
An object is an instance of a class.
Declaring Objects:
Creating objects is similar to declaring variables and
can be done using the syntax:-
<Class Name> <Object Name>;
Example:
Student S1;
Class:
We just mentioned that objects contain data, and code to
manipulate that data.
The entire set of data and code of an object can be made
a user-defined data type with the help of a class.
The objects are variables of the type class.
Once a class has been defined, we can create any number
of objects belonging to that class.
Declaring Classes:
We declare classes using the following syntax:-
class < Class Name >
{
data members…
member functions…
}
Here class is a keyword.
Rules for naming classes:
* A class name must begin with a letter & can be
followed by a sequence of letters (A-Z), digits
(0-9)m,underscore (_)
* Special Characters such as ? - + * / \ ! @ # $ % ^ ( )
[ ] { } , ; : . cannot be used in the class name.
* A class name must not be the same as a reserved
keyword such as using, public, etc.
Data Abstraction and Encapsulation:
The wrapping up of data and functions into a single unit
is known as encapsulation.
Data encapsulation is the most striking feature of a class.
Abstraction refers to the act of representing essential
features without including the background details or
explanations.
Encapsulation is the hiding of information in order to
ensure that data structures and operators are used as
intended and to make the usage model more obvious to the
developer.
C++ provides the ability to define classes and functions
as its primary encapsulation mechanisms.
The figure is an example of data abstraction to
abstract doors as a data structure with essential properties.
Inheritance:
Inheritance is the process by which objects of one class
acquire the properties of objects of another class.
It supports the concept of hierarchical classification.
Creating new class is also known as the derived class
The existing class is also called the baseclass.
where Circle and Rectangle inherit from GeomFigure and
own all attributes and methods from GeoFigure.
Reusability:
The concept of inheritence provides an important feature
to the object-oriented lanuage-reusability.
A programmer can take an existing class and, without
modifyinh it, and additional features and capabilities to it.
This is done by deriving a new class from an existing class.
Polymorphism:
Polymorphism is another important OOP concept.
The word polymorphism is derived from two Latin words
poly (many) and morphos(forms).
An operation many exhibit different behaviours in
different instances..
The behaviour depends upon the types of data used in the
operation.
Dynamic Binding:
Binding refers to the linking of a procedure call to the
code to be executed in response to the call.
Dynamic binding means that the code associated with a
given procedure call is not known until the time of the call
at run-time.
It is associated with polymorphism and inheritance.
Message passing:
An object oriented program consists of a set of objects
that communicte with each other.
The process of programming in an object oriented
language,and it involves the following steps
Creating classes that define objects and their behaviour
Creating objects from class definitions ,and
Establishing communication among objects.
| Is This Answer Correct ? | 15 Yes | 6 No |
Post New Answer View All Answers
write a C++ program for booking using constructor and destructor.
why reinterpret cast is considered dangerous?
Advantage and disadvantage of routing in telecom sector
Why do pointers exist?
What is oops in simple words?
How to hide the base class functionality in Inheritance?
How can you overcome the diamond problem in inheritance?
What is abstract class in oop?
Which language is not a true object oriented programming language?
Explain virtual inheritance?
What is the important feature of inheritance?
What is destructor example?
Why is abstraction used?
How do you define a class in oop?
This program numbers the lines found in a text file. Write a program that reads text from a file and outputs each line preceded by a line number. Print the line number right-adjusted in a field of 3 spaces. Follow the line number with a colon, then one space, then the text of the line. You should get a character at a time and write code to ignore leading blanks on each line. You may assume that the lines are short enough to fit within a line on the screen. Otherwise, allow default printer or screen output behavior if the line is too long (i.e., wrap or truncate). A somewhat harder version determines the number of spaces needed in the field for the line numbers by counting lines before processing the lines of the file. This version of the program should insert a new line after the last complete word that will fit within a 72-character line.