Read and download the CBSE Class 12 Computer Science Class And Objects Worksheet Set B in PDF format. We have provided exhaustive and printable Class 12 Computer Science worksheets for Class And Objects, designed by expert teachers. These resources align with the 2025-26 syllabus and examination patterns issued by NCERT, CBSE, and KVS, helping students master all important chapter topics.
Chapter-wise Worksheet for Class 12 Computer Science Class And Objects
Students of Class 12 should use this Computer Science practice paper to check their understanding of Class And Objects as it includes essential problems and detailed solutions. Regular self-testing with these will help you achieve higher marks in your school tests and final examinations.
Class 12 Computer Science Class And Objects Worksheet with Answers
1 Write the definition for a class called Rectangle that has floating point data members length and width. The class has the following member functions:
void setlength(float) to set the length data member
void setwidth(float) to set the width data member
float perimeter() to calculate and return the perimeter of the rectangle
float area() to calculate and return the area of the rectangle
void show() to display the length and width of the rectangle
int sameArea(Rectangle) that has one parameter of type Rectangle. sameArea returns 1 if the two Rectangles have the same area, and returns 0 if they don't.
1. Write the definitions for each of the above member functions.
2. Write main function to create two rectangle objects. Set the length and width of the first rectangle to 5 and 2.5. Set the length and width of the second rectangle to 5 and 18.9. Display each rectangle and its area and perimeter.
3. Check whether the two Rectangles have the same area and print a message indicating the result. Set the length and width of the first rectangle to 15 and 6.3. Display each Rectangle and its area and perimeter again. Again, check whether the two Rectangles have the same area and print a message indicating the result.
1. Define a class STUDENT with the following specifications
Private members:
Grno long integer
Name 20 characters
Marks in 5 subjects, each out of 100 an array of 5 float values
Total, percentage float
Calculate() Function to calculate total & percentage
Public functions
takedata() Function to read Grno, name and 5 marks of a student
displaydata() to invoke Calculate() function and to display all the details of the student
Write a Program to implement the above class for a student.
2. Define a class EMPLOYEE with the following specifications
Private data members
Empno integer
Name 20 characters
Basicpay float
HRA, DA, PF float
Netpay double
Public functions
Getdata() Function to read empno, name and basicpay of an Employee
Compute() Function to compute HRA (10% of basicpay), DA (50% of basicpay), PF (8% of basicpay) and netpay as basicpay + HRA + DA – PF and return the calculated Netpay.
Printdata() to invoke Compute() function and to display all the details of an employee
Write a Program to read details (empno, name and basicpay) for n employees and compute netpay for them and display all the details.
CLASSES AND OBJECTS
Q1. What is class? What is its need? Classes
A class is a way to bind the data describing an entity and its associated functions together. In C++ , class makes a data type that is used to create objects of this type. Need for classes
Classes are needed to represent real-world entities that not only have data type properties (Characteristics) but also have associated operations (their behaviour)
Q2 . Differentiate between local and global class with help of example.
Answer : 1. Global Class
A class is said to be global it its declaration occurs outside the bodies of all functions in a program.
2. Local class
A class is said to be local if its occurs inside the function body
# include<iostream.h>
class x //x is a global class
{
members variable functions of class;
};
x ob1; //global object
int main ( )
{
class num // num is local class
{
public:
int a=10;
void num( ) // constructor (same name of class)
{
cout<<num;
};
x ob2; //local object of class x
num n1; // n1is a class object
n1.num( );
} // closing of main ()
Q3. What do you mean by nested class ?Explain.
Answer : Nested class
Declaration of one class in to another class is called is called nested of a class.
#include<iostream.h>
#include<conio.h> // for clrscr()
class score
{
int a; //private member variable
class batesman // nested class
{
int b;
public:
int c;
void total( )
{
cin>>b>>c;
int sum = b+c;
}
batesman( )
{
c=10;
}
}; // end of class batesman
batesman obj2; // object of class batesman
void second( void)
{
cout<<score :: second()<<endl;
cout<<”A =” <<a
}
score( )
{
a= 25;
}
}; //end of class score;
void main()
{
score ab;
batesman bc;
score :: batesman cd;
ab.second();
bc.total();
cd.total();
}
Q4. What are the advantages and disadvantages of inline functions?
Answer : The main advantages of inline functions is that they save on the overheads of a function call as the function is not invoked, rather its code is replaced in the program.
The major disadvantage of inline functions is that with more function calls, more memory is wasted as for every function call, the same function code is inserted in the program. Repeated occurrences of same function code waste memory space.
Q5. What do you understand by member function?
Answer : Member function have full access privilege to both the public and private members of the class. These are defined within the class scope that is they are not visible outside the scope of class.
But not member functions are visible outside the class (ordinary functions)
Q6. What are static class members?
Answer : A class can have static data members as well as static member functions The static data members are the class variables that are common for all the objects of the class. Only one copy of static data members is maintained which is shared by all the objects of the class. They are visible only with in the class
Q7. Identify the errors in the following code fragment:
class ab
{
int x;
static int ctr;
Public:
Void init(void) {
x=ctr=0; }
static void print(void) {
cout<<ctr<<x; } };
Answer : In the above code fragment, a static member function is trying to access a non static member that is ‘x’ which is the error
The correct code for static member function is
static void print(void)
{
cout<<ctr; }
Q8. What is the significance of access specifiers in a class?
Answer : A class provides three access specifiers namely private, public and protected
(a) A data member declared as private or protected remains hidden from outside world and it can only be accessed by the member functions of the class.
(b) A data member declared as public is made available to the outside world. That is, it can be accessed by any function, any expression in the program but only by using an object of the same class type.
These access labels enforce data hiding and abstraction also.
Q9 . Write the output of the following code
#include<iostream.h>
class counter {
private:
unsigned int count;
public:
counter() // constructor
{
count=0; }
void inc_count( ) // increment in count variable
{
count ++; }
int get_count( ) {
return count; }
};
void main()
{
counter c1,c2;
cout<< “ \n value for c1 is:” <<c1.get_count( );
cout<< “ \n value for c2 is:” <<c2.get_count( );
c1.inc_count();
c2.inc_count();
c2.inc_count();
cout<< “\t c1=” <<c1.get_count();
cout<< “\t c2=” <<c2.get_count(); }
Answer : The output will be
c1=0 c2=0 c1=1 c2=2
Chapter – 4 CONSTRUCTOR AND DESTRUCTORS
Q1. What is Constructor ?
Answer : Constructors:
A constructor is a special member function of a class that is automatically called, when an object is created of that class. A member function with the same name as its class is called constructor.
Q2. What is destructor ? What is its need ?
Answer : Destructor:
A destructor is also a member function whose name is the same as the class name but is preceded by tilde (‘~’)
A destructor takes no arguments and no return types can be specified for it. It is called automatically by the compiler when an object is destroyed. A destructor cleans up the storage ( memory area of the object) that is no longer accessible. Need for Destructors
Allocated resources (like constructor) must be de-allocated before the object is destroyed. It works as a de-allocating and releasing memory area and it perform our works as a clean up tasks. Therefore, a destructor is equally useful as a constructor is.
class stud
{
stud() //constructor
{
cout << “ welcome”
| CBSE Class 12 Computer Science Revision Worksheet Set A |
| CBSE Class 12 Computer Science Revision Worksheet Set B |
| CBSE Class 12 Computer Science Revision Worksheet Set C |
| CBSE Class 12 Computer Science Boolean Algebra Worksheet Set A |
| CBSE Class 12 Computer Science Boolean Algebra Worksheet Set B |
| CBSE Class 12 Computers Boolean Algebra Worksheet |
| CBSE Class 12 Computer Science C++ Programming Worksheet |
| CBSE Class 12 Computer Science Case Study Based Questions |
| CBSE Class 12 Computer Science Class And Objects Worksheet Set A |
| CBSE Class 12 Computer Science Class And Objects Worksheet Set B |
| CBSE Class 12 Computers Classes And Objects Worksheet |
| CBSE Class 12 Computer Science Classes Objects Constructors And Destructors Worksheet |
| CBSE Class 12 Computer Science Communication And Network Concepts Worksheet |
| CBSE Class 12 Computer Science Computer Networking Worksheet |
| CBSE Class 12 Computer Science Constructors And Destructors Worksheet |
| CBSE Class 12 Computers Constructors And Destructors Worksheet |
| CBSE Class 12 Computer Science Data File Handling Worksheet |
| CBSE Class 12 Computers Data Structures Worksheet |
| CBSE Class 12 Computer Science Database Concepts And Sql Worksheet |
| CBSE Class 12 Computer Science Dbms And Structured Query Language Worksheet |
| CBSE Class 12 Computer Science Flow Of Control Worksheet |
| CBSE Class 12 Computer Science Function And Structures Worksheet |
| CBSE Class 12 Computer Science Function Overloading Worksheet |
| CBSE Class 12 Computer Science Fundamentals Of Computer Worksheet |
| CBSE Class 12 Computer Science Inheritance Extending Classes Worksheet |
| CBSE Class 12 Computer Science Linked Lists Stacks And Queues Worksheet |
| CBSE Class 12 Computer Science Network And Communication Technology Worksheet |
| CBSE Class 12 Computer Science Object Oriented Programming Worksheet |
| CBSE Class 12 Computers Object Oriented Programming Worksheet |
| CBSE Class 12 Computer Science Object Oriented Programming In C++ Worksheet |
| CBSE Class 12 Computer Science Oop Classes And Objects Worksheet |
| CBSE Class 12 Computer Science Programming In C++ Worksheet |
| CBSE Class 12 Computer Science SQL Worksheet Set A |
| CBSE Class 12 Computer Science SQL Worksheet Set B |
| CBSE Class 12 Computer Science Stacks Queues And Linked List Worksheet |
Important Practice Resources for Class 12 Computer Science
CBSE Computer Science Class 12 Class And Objects Worksheet
Students can use the practice questions and answers provided above for Class And Objects to prepare for their upcoming school tests. This resource is designed by expert teachers as per the latest 2026 syllabus released by CBSE for Class 12. We suggest that Class 12 students solve these questions daily for a strong foundation in Computer Science.
Class And Objects Solutions & NCERT Alignment
Our expert teachers have referred to the latest NCERT book for Class 12 Computer Science to create these exercises. After solving the questions you should compare your answers with our detailed solutions as they have been designed by expert teachers. You will understand the correct way to write answers for the CBSE exams. You can also see above MCQ questions for Computer Science to cover every important topic in the chapter.
Class 12 Exam Preparation Strategy
Regular practice of this Class 12 Computer Science study material helps you to be familiar with the most regularly asked exam topics. If you find any topic in Class And Objects difficult then you can refer to our NCERT solutions for Class 12 Computer Science. All revision sheets and printable assignments on studiestoday.com are free and updated to help students get better scores in their school examinations.
You can download the latest chapter-wise printable worksheets for Class 12 Computer Science Chapter Class And Objects for free from StudiesToday.com. These have been made as per the latest CBSE curriculum for this academic year.
Yes, Class 12 Computer Science worksheets for Chapter Class And Objects focus on activity-based learning and also competency-style questions. This helps students to apply theoretical knowledge to practical scenarios.
Yes, we have provided solved worksheets for Class 12 Computer Science Chapter Class And Objects to help students verify their answers instantly.
Yes, our Class 12 Computer Science test sheets are mobile-friendly PDFs and can be printed by teachers for classroom.
For Chapter Class And Objects, regular practice with our worksheets will improve question-handling speed and help students understand all technical terms and diagrams.