KnowledgeBoat Logo
OPEN IN APP

Chapter 1 - Unit 2

Elementary Concept of Objects and Classes

Class 10 - APC Understanding Computer Applications with BlueJ



Multiple Choice Questions

Question 1

Which of the following keywords is used to create an instance of a class?

  1. new
  2. public
  3. class
  4. main

Answer

new

Reason — New keyword is used to create an instance of a class.

Question 2

The ............... is called an instance of a class.

  1. attribute
  2. object
  3. state
  4. features

Answer

object

Reason — The data members declared within a class are known as instance variables. When an object of a class is created, it includes instance variables described within the class. Hence, an object is called as an instance of a class.

Question 3

The objects we see around us are called as:

  1. Real world object
  2. Virtual object
  3. Imaginary object
  4. None of the above

Answer

Real world object

Reason — The objects we see around us are called as Real world objects.

Question 4

Which of the following makes a function non-returnable?

  1. public
  2. static
  3. void
  4. new

Answer

void

Reason — The keyword 'void' makes a function non-returnable.

Question 5

Which of the following statements is valid for the objects?

  1. They possess same characteristics and behaviour.
  2. They possess same characteristics but different behaviour.
  3. They possess different characteristics and different behaviour.
  4. They possess different characteristics but common behaviour.

Answer

They possess different characteristics but common behaviour.

Reason — Objects are the entities which possess different characteristics and common behaviour described within the class.

Fill in the blanks

Question 1

Creating object is the fundamental concept in object oriented programming language.

Question 2

A class is also considered as an object factory.

Question 3

A real world object deals with characteristics and behaviours.

Question 4

The object of a class differs on various characteristics.

Question 5

The characteristics of the real world objects are considered to be the data members of the software objects.

Question 6

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.

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 is used to create similar objects that possess different characteristics and common behaviour. Hence, class is called an object factory.

Question 5

Why is a class known as composite data type?

Answer

When a user creates a class, it becomes a data type for his program. This data type includes different primitive types such as int, float, char, etc. Thus, class is referred to as a user defined data type or 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

The data members declared within a class are also known as instance variables. When an object of a class is created, it includes instance variable described within the class. This is the reason that 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

(b) class Bike

(c) class Fruits

(d) class Pen

Answer

(a) class Mobile Phone

CharacteristicsMethods
colourmakeCall()
modelreceiveCall()
IMEI Number 

(b) class Bike

CharacteristicsMethods
colourstartEngine()
modelstopEngine()
Registration Number 

(c) class Fruits

CharacteristicsMethods
namebuy()
quantitysell()
cost 

(d) class Pen

CharacteristicsMethods
namewrite()
typerefill()
Company 

Question 11

Design a program in Java 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

PrevNext