LESSON 1
Concept of OOPs
Object-oriented programming: Object-Oriented Programming or OOPs refers to languages that uses objects
in programming. Object-oriented programming aims to implement real-world entities like abstraction ,
inheritance, encapsulation , polymorphism etc in programming. Java is an example of object oriented
language.
Ques. What are the basic OOP (object oriented programming) concepts? OR Name OOPs principles
Ans : The basic OOP concepts are Abstraction, Encapsulation, Inheritance, Polymorphism
Ques. What is an object ? Give eg.
Ans An object is an identifiable entity with some characteristics and behaviour. For e. g. Orange is an
object. Its characteristics are its spherical shape and its orange colour. Its behaviour is that it is citrus in
nature and tastes sweet and sour.
Ques. What is an abstraction? Give example .
Ans Abstraction is an act of representing essential features without including background details or
explanations. For Eg If a person is driving a car he is required to know the essential features like use
of gear, clutch, brakes, accelerator and steering handling etc. He is not required to know the internal
details like wiring , functioning of engine etc.
Ques. What is Encapsulation ? Give eg
Ans The wrapping up of data and functions in a single unit is called encapsulation.
For eg . a group of car’s part (such as seats, steering ,engine ,brakes etc.) does not make a car ; they have
to be connected in proper way in one unit in order to have proper functionality i.e behaviour. ; then only
it may be termed as a car.
Ques. What is Polymorphism?
Ans Polymorphism is the ability of an object to behave differently in different circumstances.
For eg operation move behaves differently when applied to MS windows than when applied
to a chess game.
Ques. What is inheritance ?
Ans Inheritance is the capability of one class to inherit the properties from another class .A class from which
another class is inheriting the properties is Base/ Super class and the class that inherits the properties is known
as Derived / Sub class
Ques. Can there be multiple abstractions of a real world entity?
Ans Yes, There can be multiple abstractions of a real-world entity as an abstraction is relative to the purpose
or user e. g., If we talk about student , we talk about anything belong to him like his name, brothers
,sisters, parent’s profession, address etc. but in terms of result tracking system the abstraction would be –
his roll no, name, marks obtained etc, for extra curricular activities , the abstraction would be – her roll
no , talents and awards etc.
Ques How are objects implemented in software terms?
Ans
The objects are implemented in software terms as
(i) Characteristics (attributes ) are implemented through member variables .
(ii)
Behaviour is implemented through member functions called methods.
(iii) The values of these member variables defines the state of an object
(iv) Data and methods are encapsulated into one unit and given a unique name to give it identity.
Ques What is state of object?
Ans In software objects , the values of the characteristics(member variables) determine the state of object.
For eg the switch may be in two state either on or off.
Ques How do object encapsulate state and behavior?
Ans An object binds together the characteristics and behaviour which cannot be separated i.e. The
state and behavior are encapsulated by the object as the state is nothing but the set of values of
the characteristics at a certain time.
Ques What is message passing among object ?
Ans The interaction between objects by means of function calls is termed as message passing
Ques What is information hiding?
Ans. Information hiding means restricting the accessibility of data associated with an object in such a way that it can be
used only through the member methods of the object.
Ques Why methods are so important for the description of objects?
Ans All the real world entities do have behaviour associated with them, so the objects, which basically represent these
entities, must have methods that implements this behaviour..
Ques How are classes and abstraction interlinked?
Ans. An Abstraction is a named collection of characteristics and behaviour required to represent an entity or concept
for some particular domain . And a class is logical implementation of an abstraction. When it comes to represent
an abstraction in software terms, it is represented through a class.
Ques How do you map an abstraction into software?
Ans . Abstractions are mapped into software terms by means of classes. A class wraps up characteristics and behavior of
an abstraction into one unit by representing characteristics(attributes) through data members and behaviour
through methods.
Ques What is class ?
Ans A class represents a set of objects that share common characteristics and behaviour.
For eg Student is a class but the students JOHN , RAM are objects.
Ques What is an object factory ?
Ans Class is an object factory that accepts some information and creates objects based on this information.
Ques How are objects and classes related to each other ?
Ans Class is a set of objects with common characteristics and behaviour, while an object is an instance of the class.
Ques. Why are classes and object needed ?
Ans: Classes are defined as a blueprint of its object. We need classes because they contain all the statements and
functions that can be used by the objects of the class.
Objects are the instances of class .They are needed because they are used to access the data member and the member
function of the class without disturbing the actual structure of the class.
Ques Why is a class called an object factory ?
Ans class is called can object factory because it contains all the statements needed to define an object its behavior ,
attributes as well as its functions that the object will be able to perform. A class can produce any number of
objects.
Ques Why is an object called the instance of the class ?
Ans An object is called an instance of a class as it has the same structure and behaviour as that of a class. A class
can have many instances or objects which have same structure and behaviour but differ only in their state.
No comments:
Post a Comment