1.What is an object? Give an
example of some real world objects.
Ans.
Object is a unique entity, which contains data and functions (Characteristics
and behaviour ) together in an Object Oriented Programing (OOP)Language. For Example: Pen is an
object. Its name is Reynolds, color is white etc. known as its state. It is
used to write, so writing is its behavior.
2.‘An object’s state and behaviour
are two distinct things yet linked to one another’ Comment
Ans.
The state of an object controls its behavior of an object can bring about a
change in its state.
3.
Define data abstraction.
Ans.
Data abstraction refers to the act of representing essential features without
including the background details or explanations.
4. Define Encapsulation.
Ans. Wrapping up of
data and functions(that operate on the data) into single unit.
5. What is message passing among
objects?
Ans.
An object can pass the information to another object and receives information as
well. They interact through message, which are better known as ‘Message Passing’.
6.What are methods ? What do they
represent ?
Ans.
A method is an operation associated to an object. The behaviour of an object is
represented through associated functions, which are called methods.
7. What is data hiding ?
Ans.
Data hiding means restricting the accessibility of data associated with an
object in such way that it can be used only through the member methods of the
object.
8. How are real world objects
implement / represented in software terms?
Ans.
You can represent real-world objects using software objects. You might want to
represent real-world dogs as software objects in an animation program or a
real-world bicycle as a software object within an electronic exercise bike.
However, you can also use software objects to model abstract concepts. For
example, an event is a common object used in GUI window systems to represent
the action of a user pressing a mouse button or a key on the keyboard.
9. What is class?
Ans.
A class is a
group of objects that has common properties. It is a template or blueprint from
which objects are created.
10. How does object encapsulate its
state and behaviour ?
Ans.
State and behaviour of object are interweaved. They are said to encapsulate
state and behaviour. e.g. a car object has characteristics like number of
wheels seats etc. its state is represented as halted, moving or stationary and
its behaviour is, it can move, stop, blow horn etc,. Now all these things are
wrapped up together in the form of car. Thus we can say the object encapsulates
their state and behaviour as their state and behaviour are interlinked, they
cannot exist separately.
11. How do objects interact with
one another ? Give an example .
Ans.
Objects interact through message, which are better known as ‘Message Passing’. A real world example: The principal of a school wants to
know the performance of his school students in the ‘Council Result’. He sends a
message from his desk(object 1) to the school office (object 2) to get the
information. The school office in turn passes the information to the Principal.
This system of
communication among the objects is referred as ‘Message Passing’.
12. Explain briefly the concept of
data abstraction with the help of an example.
Ans.
Abstraction is process of hiding the implementation
details & showing only the functionality.
For example: If somebody in your collage tell you to fill application form, you will fill your details like name, address, data of birth, which semester, percentage you have got etc. If some doctor gives you an application to fill the details, you will fill the details like name, address, date of birth, blood group, height and weight.
The common thing: Age, name, address so you can create the class which consist of common thing that is called abstract class. Since class uses the property of abstraction, it is also called as abstract data type or data abstraction.
For example: If somebody in your collage tell you to fill application form, you will fill your details like name, address, data of birth, which semester, percentage you have got etc. If some doctor gives you an application to fill the details, you will fill the details like name, address, date of birth, blood group, height and weight.
The common thing: Age, name, address so you can create the class which consist of common thing that is called abstract class. Since class uses the property of abstraction, it is also called as abstract data type or data abstraction.
13.Explain briefly the concept of
encapsulation with the help of an example.
Ans.
Encapsulation in java is a process of wrapping code and data together into a
single unit, for example capsule i.e. mixed of several medicines. We can create
a fully encapsulated class in java by making all the data members of the class
private. Now we can use setter and getter methods to set and get the data in it.
The Java Bean class is the example of fully encapsulated class.
14. How the data is hidden and safe
if encapsulation is implemented ? Explain with an example.
Ans.
Encapsulation is an Object Oriented Programming concept that binds together the
data and functions that manipulate the data, and that keeps both safe from
outside interference and misuse. Data encapsulation led to the important OOP
concept of data hiding.
Let's
take one real life example of a TV, which you can turn on and off, change the
channel, adjust the volume, and add external components such as speakers, VCRs,
and DVD players, BUT you do not know its internal details, that is, you do not
know how it receives signals over the air or through a cable, how it translates
them, and finally displays them on the screen.
15. Simulate a daily life example
that explains encapsulation.
Ans.
Wrapping
up data member and method together into a single unit (i.e. Class) is called
Encapsulation.
Encapsulation
is like enclosing in a capsule. That is enclosing the related operations and
data related to an object into that object.
Encapsulation
is like your bag in which you can keep your pen, book etc. It means this is the
property of encapsulating members and functions.
16. Write a short note on
inheritance.
Ans.
Inheritance
is the process in which objects of one class can link and share some common
properties of the objects with another class.
For
example , Car is a classification of Four Wheeler. Here Car acquires the properties
of a four-wheeler. Other classifications could be a jeep, tempo, van etc. Four
Wheeler defines a class of vehicles that have four wheels, and specific range of
engine power, load carrying capacity etc. Car (termed as a sub-class) acquires these
properties from Four Wheeler (termed as a super-class), and has some specific
properties, which are different from other classifications of Four Wheeler,
such
as luxury, comfort, shape, size, usage etc.