Chapter 2 Question answers
Chapter 2 Question answers
Answers
1. What are objects? Give five examples.
Answer: Objects are identifiable entities with attributes, behavior, and state. They are the basic
units of an object-oriented system.
Examples:
• Mobile
• Car
• Chair
• Bank Account
• Person
5. Identify five possible attributes and three possible behaviours of the following entities:
Answer:
a. School
• Attributes: Name, address, number of classrooms, principal, established year.
• Behaviors: Conduct classes, organize events, issue certificates.
b. Student
• Attributes: Name, roll number, grade, date of birth, address.
• Behaviors: Study, attend classes, submit assignments.
c. Teacher
• Attributes: Name, subject, employee ID, qualification, experience.
• Behaviors: Teach, evaluate assignments, conduct tests.
d. Computer
• Attributes: Brand, processor, RAM, storage, operating system.
• Behaviors: Run programs, connect to the internet, save files.
e. Television
• Attributes: Brand, screen size, resolution, model, channel list.
• Behaviors: Change channels, adjust volume, display content.
f. Washing Machine
• Attributes: Brand, capacity, model, water level, wash modes.
• Behaviors: Wash clothes, spin, dry clothes.
g. Chair
• Attributes: Material, color, height, weight, design.
• Behaviors: Support weight, adjust height (if adjustable), fold (if foldable).
h. Person
• Attributes: Name, age, address, eye color, Aadhaar number.
• Behaviors: Walk, talk, drive.
8. How are classes and objects inter-related? Support your answer with an example.
Answer: A class defines the structure (attributes and behaviors) for objects, and objects are
instances created from that class. They are inter-related as a class is the template, and objects are
its realizations.
Example: The Account class defines attributes like balance and methods like deposit. Objects
myAccount and yourAccount are created from this class, each with specific balances but sharing
the same structure.
9. What do you understand by the term objects encapsulate state and behaviour?
Answer: Encapsulation means an object stores its state (attribute values) in member variables
and exposes its behavior through methods. Only these methods can access or modify the state,
hiding internal details. For example, a Mobile object’s state (model: Samsung) is changed only
by its methods like dial, keeping data secure.