CBSE Class 12 Computer Science Class And Objects Worksheet Set B

Read and download free pdf of CBSE Class 12 Computer Science Class And Objects Worksheet Set B. Students and teachers of Class 12 Computer Science can get free printable Worksheets for Class 12 Computer Science Class And Objects in PDF format prepared as per the latest syllabus and examination pattern in your schools. Class 12 students should practice questions and answers given here for Computer Science in Class 12 which will help them to improve your knowledge of all important chapters and its topics. Students should also download free pdf of Class 12 Computer Science Worksheets prepared by school teachers as per the latest NCERT, CBSE, KVS books and syllabus issued this academic year and solve important problems with solutions on daily basis to get more score in school exams and tests

Worksheet for Class 12 Computer Science Class And Objects

Class 12 Computer Science students should refer to the following printable worksheet in Pdf for Class And Objects in Class 12. This test paper with questions and answers for Class 12 will be very useful for exams and help you to score good marks

Class 12 Computer Science Worksheet for Class And Objects

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”

More Worksheets for Class 12 Computer Science
CBSE Class 12 Computer Science Arrays Stacks Queues And Linked List Worksheet Set A
CBSE Class 12 Computer Science Arrays Stacks Queues And Linked List Worksheet Set B
CBSE Class 12 Computer Science Arrays Worksheet
CBSE Class 12 Computer Science Boolean Algebra Worksheet Set A
CBSE Class 12 Computer Science Boolean Algebra Worksheet Set B
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 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 Computer Science Data File Handling 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 Overloading Worksheet
CBSE Class 12 Computer Science Function And Structures 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 In C++ Worksheet
CBSE Class 12 Computer Science Object Oriented Programming Worksheet
CBSE Class 12 Computer Science Oop Classes And Objects Worksheet
CBSE Class 12 Computer Science Pointer Worksheet
CBSE Class 12 Computer Science Program List Worksheet
CBSE Class 12 Computer Science Programming In C++ Worksheet
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 SQL Worksheet Set A
CBSE Class 12 Computer Science SQL Worksheet Set B
CBSE Class 12 Computer Science Stacks Queues And Linked List Worksheet
CBSE Class 12 Computer Science Sure Shot Questions Worksheet Set A
CBSE Class 12 Computer Science Sure Shot Questions Worksheet Set B
CBSE Class 12 Computer Science Sure Shot Questions Worksheet Set C
CBSE Class 12 Computer Science Sure Shot Questions Worksheet Set D
CBSE Class 12 Computer Science Text Files Worksheet
CBSE Class 12 Computers Boolean Algebra Worksheet
CBSE Class 12 Computers Classes And Objects Worksheet
CBSE Class 12 Computers Constructors And Destructors Worksheet
CBSE Class 12 Computers Data Structures Worksheet
CBSE Class 12 Computers Files Worksheet
CBSE Class 12 Computers Inheritance Worksheet Set A
CBSE Class 12 Computers Inheritance Worksheet Set B
CBSE Class 12 Computers Networking Worksheet
CBSE Class 12 Computers Object Oriented Programming Worksheet
CBSE Class 12 Computers Pointers Worksheet

More Study Material

CBSE Class 12 Computer Science Class And Objects Worksheet

We hope students liked the above worksheet for Class And Objects designed as per the latest syllabus for Class 12 Computer Science released by CBSE. Students of Class 12 should download in Pdf format and practice the questions and solutions given in the above worksheet for Class 12 Computer Science on a daily basis. All the latest worksheets with answers have been developed for Computer Science by referring to the most important and regularly asked topics that the students should learn and practice to get better scores in their class tests and examinations. Studiestoday is the best portal for Class 12 students to get all the latest study material free of cost.

Worksheet for Computer Science CBSE Class 12 Class And Objects

Expert teachers of studiestoday have referred to the NCERT book for Class 12 Computer Science to develop the Computer Science Class 12 worksheet. If you download the practice worksheet for one chapter daily, you will get higher and better marks in Class 12 exams this year as you will have stronger concepts. Daily questions practice of Computer Science worksheet and its study material will help students to have a stronger understanding of all concepts and also make them experts on all scoring topics. You can easily download and save all revision worksheet for Class 12 Computer Science also from www.studiestoday.com without paying anything in Pdf format. After solving the questions given in the worksheet which have been developed as per the latest course books also refer to the NCERT solutions for Class 12 Computer Science designed by our teachers

Class And Objects worksheet Computer Science CBSE Class 12

All worksheets given above for Class 12 Computer Science have been made as per the latest syllabus and books issued for the current academic year. The students of Class 12 can be rest assured that the answers have been also provided by our teachers for all worksheet of Computer Science so that you are able to solve the questions and then compare your answers with the solutions provided by us. We have also provided a lot of MCQ questions for Class 12 Computer Science in the worksheet so that you can solve questions relating to all topics given in each chapter. All study material for Class 12 Computer Science students have been given on studiestoday.

Class And Objects CBSE Class 12 Computer Science Worksheet

Regular worksheet practice helps to gain more practice in solving questions to obtain a more comprehensive understanding of Class And Objects concepts. Worksheets play an important role in developing an understanding of Class And Objects in CBSE Class 12. Students can download and save or print all the worksheets, printable assignments, and practice sheets of the above chapter in Class 12 Computer Science in Pdf format from studiestoday. You can print or read them online on your computer or mobile or any other device. After solving these you should also refer to Class 12 Computer Science MCQ Test for the same chapter.

Worksheet for CBSE Computer Science Class 12 Class And Objects

CBSE Class 12 Computer Science best textbooks have been used for writing the problems given in the above worksheet. If you have tests coming up then you should revise all concepts relating to Class And Objects and then take out a print of the above worksheet and attempt all problems. We have also provided a lot of other Worksheets for Class 12 Computer Science which you can use to further make yourself better in Computer Science

Where can I download latest CBSE Printable worksheets for Class 12 Computer Science Class And Objects

You can download the CBSE Printable worksheets for Class 12 Computer Science Class And Objects for latest session from StudiesToday.com

Can I download the Printable worksheets of Class And Objects Class 12 Computer Science in Pdf

Yes, you can click on the links above and download Printable worksheets in PDFs for Class And Objects Class 12 for Computer Science

Are the Class 12 Computer Science Class And Objects Printable worksheets available for the latest session

Yes, the Printable worksheets issued for Class 12 Computer Science Class And Objects have been made available here for latest academic session

How can I download the Class 12 Computer Science Class And Objects Printable worksheets

You can easily access the links above and download the Class 12 Printable worksheets Computer Science Class And Objects for each chapter

Is there any charge for the Printable worksheets for Class 12 Computer Science Class And Objects

There is no charge for the Printable worksheets for Class 12 CBSE Computer Science Class And Objects you can download everything free

How can I improve my scores by solving questions given in Printable worksheets in Class 12 Computer Science Class And Objects

Regular revision of practice worksheets given on studiestoday for Class 12 subject Computer Science Class And Objects can help you to score better marks in exams

Are there any websites that offer free test sheets for Class 12 Computer Science Class And Objects

Yes, studiestoday.com provides all latest NCERT Class And Objects Class 12 Computer Science test sheets with answers based on the latest books for the current academic session

Can test papers for Class 12 Computer Science Class And Objects be accessed on mobile devices

Yes, studiestoday provides worksheets in Pdf for Class And Objects Class 12 Computer Science in mobile-friendly format and can be accessed on smartphones and tablets.

Are worksheets for Class And Objects Class 12 Computer Science available in multiple languages

Yes, worksheets for Class And Objects Class 12 Computer Science are available in multiple languages, including English, Hindi