You are on page 1of 9

An object of a class is created by using a

keyword new.

Question 7

Class is a blueprint of the objects.

Question 8

new keyword is used for dynamic


allocation of an object.

Question 9

The living things are considered as real


world objects.

Question 10

The different objects of a class have


common behaviours.

Answer the following questions

Question 1

How will you define a software object?

Answer

A software object replaces the


characteristics and behaviours of a real
world object with data members and
member methods, respectively.

Question 2

Define class and object with an example.

Answer
An object is an entity having a specific
identity, specific characteristics and
specific behavior. A class is a blue print
that represents a set of objects that
share common characteristics and
behaviour. Take the example of a
house. An architect will have the
blueprints for a house. Those
blueprints will be plans that explain
exactly what properties the house will
have and how they are all laid out.
However, it is just the blueprint, we
can't live in it. Builders will look at the
blueprints and use those blueprints to
make a physical house. They can use
the same blueprint to make as many
houses as they want. Each house will
have the same layout and properties.
Each house can accommodate its own
families. So, in this example, the
blueprint is the class, the house is the
object and the people living in the
house are data stored in the object's
properties.

Question 3

What does the following statement mean?


Employee staff = new Employee ( );

Answer

This statement creates a new object of


class Employee. The newly created
object is assigned to a variable named
staff which is of Employee type. The
object can be accessed using staff
variable.

Question 4

A class is also referred to as 'Object


Factory'. Comment.

Answer

A class has the complete description of


the data elements the object will
contain, the methods the object can
do, the way these data elements and
methods can be accessed. A class can
create objects of itself with different
characteristics and common behaviour
just like a factory can produce similar
items based on a particular design.
Hence, class is also referred to as
'Object Factory'.

Question 5

Why is a class known as composite data


type?

Answer

A class can contain data members of


various primitive and reference data
types. Hence, class is known as
composite data type.
Question 6

A statement is given as:


'Study_Table' is an object of the class
'Furniture'. Write down Java statement for
the same.

Answer

Furniture Study_Table = new


Furniture();

Question 7

Class and Objects are inter-related.


Explain.

Answer

A Class is used to create various


Objects that have different
characteristics and common
behaviours. Each object follows all the
features defined within a class. That is
why class is also referred to as a blue
print or prototype of an object. This
way we can say that they are inter-
related.

Question 8

Why is an Object called an 'Instance' of a


class? Explain.

Answer

A class can create objects of itself with


different characteristics and common
behaviour. So, we can say that an
Object represents a specific state of
the class. For these reasons, an Object
is called an Instance of a Class.

Question 9

Write a statement to create an object


'Keyboard' of the class 'Computer'.

Answer

Computer Keyboard = new Computer();

Question 10

Mention three characteristics and two


methods for the following Classes:

(a) Class Mobile Phone

Answer

Characteristics Methods

colour makeCall()

model receiveCall()

IMEI Number

(b) Class Bike

Answer

Characteristics Methods

colour startEngine()
Characteristics Methods

model stopEngine()

Registration Number

(c) Class Fruits

Answer

Characteristics Methods

name buy()

quantity sell()

cost

(d) Class Pen

Answer

Characteristics Methods

name write()

type refill()

Company

Question 11

Design a class program to calculate the


discount given to a customer on
purchasing LED Television. The program
also displays the amount paid by the
customer after discount. The details are
given as:
Class name : Television
Data members: int cost, int discount, int
amount
Member functions:
Accept( ) : to input the cost of Television
Calculate( ) : to calculate the discount
Display( ) : to show the discount and the
amount paid after discount

Answer

class Television {
int cost;
int discount;
int amount;

void Accept() {
/*
* Input the cost
* of Television
*/
}

void Calculate() {
/*
* Calculate the discount
*/
}

void Display() {
/*
* Show the discount and
* the amount paid
* after discount
*/
}
}

Video Explanations

You might also like