Read and download free pdf of CBSE Class 12 Computer Science Inheritance Extending Classes Worksheet. Students and teachers of Class 12 Computer Science can get free printable Worksheets for Class 12 Computer Science Inheritance Extending Classes 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 teachers as per the latest Computer Science 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 Inheritance Extending Classes
Class 12 Computer Science students should refer to the following printable worksheet in Pdf for Inheritance Extending Classes 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 Inheritance Extending Classes
Inheritance
Inheritance is the process of creating a new class from existing class/classes. The existing class is known as the base/super/parent class and newly created class is known as derived/sub/child class. The derived class will inherits the properties of base class. Advantages of Inheritance are given below:
Reusability: It helps the code to be reused in derived class. The base class is defined and once it is compiled, it needs not to be reworked.
Transitivity: If class B inherits properties of another class A, then all subclasses of class B will automatically inherits the properties of A. It is called transitive property.
Types of Inheritance:
1. Single inheritance:- When a sub class inherits only from one base class, is known as single inheritance.
2. Multiple Inheritance:- When a sub class inherits from multiple base classes, is known as multiple inheritance.
3. Hierarchical Inheritance:- When many sub classes inherit from a single class, it is known as hierarchical inheritance.
4. Multilevel Inheritance:-When a class inherit from a class that itself inherits from another class it is known as a multilevel inheritance.
5. Hybrid Inheritance: It is a combination of 2 or more of above types of inheritance. There is no pattern of deriving from classes.
Q1. What is Inheritance ?
Answer . It is a special feature of OOPS. Inheritance is capability to inherit the properties of one class in to another class.
The derive new class is called derived class (sub class) and old class is called based class (super class).
The Class whose properties of data members are inherited, is called Base Class or Super Class and the class that inherits these properties, is called Derived Class or Sub Class.
Exp1:- If Class A inherits the data of Class B then we can say A is Sub Class and B is super class.
5. Hybrid Inheritance
It is combination of two or more forms of inheritance.
Q2. What do you mean by Base and Derived Class ?
Answer . A derived class (or sub class) has to identify the class from which it is derived i.e. its base class (or super class)
class derived-class-name : visibility-mode base-class-name
{
members of derived class;
};
class is a key word and visibility mode is a access speicifier (i.e. public, private or protected), : (colon) is used separation
colon (:) indicates derived class (sub class) is based on base class( super class)
Example
class car : public automobile
{
members
};
Q3. What is Multiple Inheritance ?
Answer . Multiple Inheritance means deriving a class from more than one base class.
Class kvschool
{
int rollno1;
void num1();
Public:
{
float kvroll;
void num2();
};
class kvstud
{
int rollno2
void num3();
Protected:
float kvroll1;
void num4();
};
class kvclass : public kvschool, public kvstud
{
int kvroll2;
protected:
void display();
};
// to complete the program deifine display () – in class kvclass
i.e. kvclass ::display()
Q4. Define the needs and objectives of Inheritance.
Answer . The major needs and objectives of inheritance are:
(i) It ensures the closeness with the real world models.
(ii) It extend the functionality of an existing class.
(iii) It establishes “a kind of” relationship.
(iv) It helps in reuse of an existing class by a subclass (reusability).
(v) It implements transitive nature( if a class Y inherits properties from class X, then all subclassY will automatically inherit the properties of X)
(vi) The redundancy can be reduced by abstracting a super class from few sub classes.
(vii) It is conept of reusability.
Q5. Give the following definitions, answer the questions that follow:-
#include <iostream.h>
class book
{
char title[20];
char author[20];
int noof pages;
public:
void read();
void show();
};
class textbook: private textbook
{
int noofchapters, noof assignments;
protected:
int standard;
void readtextbook();
void showtextbook();
};
class physicsbook: public textbook
{
char topic[20];
public:
void readphysicsbook();
void showphysicsbook();
};
(i) Name the members, which can be accessed from the member functions of class physicsbook.
(ii) Name the members, which can be accessed by an object of Class textbook.
(iii) Name the members, which can be accessed by an object of Class physicsbook.
(iv) What will be the size of an object (in bytes) of class physicsbook.
Answer . (i) standard , readtextbook(),showtextbook() and topic;
(ii) readtextbook() and showtextbook()
(iii) readphysicsbook(), showphysicsbook(), readtextbook() and showtextbook()
(iv) The size of object of physicsbook= size of book + size of Textbook + size of physicsbook.
= 42+6+20 = 68 bytes
Q6. Consider the following declarations and answer the questions given below:
Class vehicle
{
int wheels;
protected:
int passenger;
public:
void inputdata( int, int);
void outputdata();
};
class heavyvehicle: protected vehicle
{
int dieselpetrol;
protected:
int load;
public:
void readdata( int, int);
void writedata();
};
class bus:private heavyvehicle
{
char marks[20];
public:
void fetchdata(char);
void displaydata();
};
(i) Name the class and derived class of the class heavyvehicle.
(ii) Name the data members that can be accessed from function displaydata()
(iii) Name the data members that can be accessed by an object of bus class
(iv) Is the member function outputdata() accessible to the objects of heavyvehicle class.
Answer .(i) base class = vehicle, derived class = bus
(ii) The data members passenger, load, make are available to function display data
(iii) No data members can be accessed by the object of bus calss.
(iv) No member functions outputdata () is not accessible to the objects of heavy vehicle class.
Q7 . What type of C++ class members ( data members and member functions) are not inherited?
Answer . Data member : Static data members of the base class are not inherited by the derived class
Member functions: Constructors and destructors of base class are not inherited
Worksheet for CBSE Computer Science Class 12 Inheritance Extending Classes
We hope students liked the above worksheet for Inheritance Extending Classes 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. Expert teachers of studiestoday have referred to the NCERT book for Class 12 Computer Science to develop the Computer Science Class 12 worksheet. 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. 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.
You can download the CBSE Printable worksheets for Class 12 Computer Science Inheritance Extending Classes for latest session from StudiesToday.com
There is no charge for the Printable worksheets for Class 12 CBSE Computer Science Inheritance Extending Classes you can download everything free
Yes, studiestoday.com provides all latest NCERT Inheritance Extending Classes Class 12 Computer Science test sheets with answers based on the latest books for the current academic session
CBSE Class 12 Computer Science Inheritance Extending Classes worksheets cover all topics as per the latest syllabus for current academic year.
Regular practice with Class 12 Computer Science worksheets can help you understand all concepts better, you can identify weak areas, and improve your speed and accuracy.