Page 51 - CA_Blue( J )_Class9
P. 51
4. Write down the difference between Class and Object.
Ans.
Class Object
Class is the blue print from which objects are created. Object is an instance of a class.
It is a logical entity that defines attributes and behaviours. It is a physical entity that exists in memory.
No memory space is allocated when a class is created. Memory space is allocated when an object is created.
A class is defined once and can be used to create as many An object is created each time it is instantiated from a
objects as needed. class.
5. What is user-defined data types? Give example.
Ans. A user-defined data type is a derived data type depending on some existing data types.
6. Class and objects are interrelated. Explain.
Ans. A class is the blueprint for an object, whereas an object is an instance of a class. Thus, classes and objects are
interrelated.
7. Write a statement to create an object ‘computer’ of the class ‘subject’.
Ans. subject computer = new subject();
21 st
D. Case Study. Century #Experiential Learning
Skills
1. You are working on a software project that involves creating multiple instances of different products in an inventory
management system. Each product has properties such as name, price, and quantity. Your team decides to create a
Product class in Java to represent these products.
The team lead mentions that "a class is an object factory," meaning that the Product class will be responsible for
generating (or "manufacturing") instances of different products in the system.
(i) Name data member/s that would be preferable for the inventory management system.
a. name b. price
c. quantity d. All of them
Ans. d
(ii) The team lead mentions that "a class is an object factory,". What is the meaning of the given line.
Ans. In object-oriented programming, we first have to define a prototype that is known as a class. Then using the class, we
can create as many as objects as we want.
2. A software company is developing an Online Course Management System for a university. The system needs to man-
age courses, instructors, and students. For simplicity, let’s focus on the Course class, which represents a course of-
fered by the university.
Each course has a title, a course code, an instructor, and a list of enrolled students. The course can have various
operations like adding a student, removing a student, and displaying course details.
(i) What is the primary purpose of the Course class in this system?
a. To represent a specific course offered by the university.
b. To manage all courses offered by the university in one place.
c. To store only the list of enrolled students in a course.
d. To track the university’s budget for each course.
Ans. b. To manage all courses offered by the university in one place.
(ii) Which of the following would be considered an object in the context of this system?
a. The name of the course.
b. The list of all courses offered by the university.
c. An instance of the Course class representing "Introduction to Computer Science."
d. The code structure of the Course class.
Ans. c. An instance of the Course class representing "Introduction to Computer Science."
Elementary Concept of Objects and Classes 49

