' Computer Science Basic Theory for CBSE Class XII Board Examination 2011 by Mr. Kapil bhatia
Tuesday 07th May 2024
REGISTRATION
Online Fashion Store

CBSE Important Questions

CBSE Guess > Papers > Important Questions > Class XII > 2011 > Computer Science > Computer Science By Mr. Kapil Bhatia

CBSE CLASS XII

Previous Index Next

Basic Theory

Page 2 sof 7

  1. Illustrate the concept of function overloading with the help of an example.

Ans: same as Q 7.

  1. Differentiate between a constructor and destructor function.

Ans same as Q9 and Q10.

  1. Illustrate the use of “self referencing structures” with the help of an example.

Ans: A self referential structure is a structure that refers to it self. A self referential structure is different from an ordinary structure in a way that self – referential structure has a structure pointer of its own type as one of its member variable
Exp:
structure student
{
int roll_no;
char name[20];
char address[40];
student *next;
};

  1. What is the purpose of a header file in a program?

Ans: The purpose of a header file in a program is that, with the help of these files we can use built-in function in our program.

  1. What do you understand about a base class & a derived class ? if a base class and a derived class each include a member function with the same name and arguments , which member function will be called by the object of the derived class if the scope operator is not used ?

Ans: The class whose members are inherited by another class is known as base class or super class and the class that inherits the members of base class is class is called derived class. Error too many types in declaration.

  1. What do you understand about a member function? How does a member function differ from an ordinary function?
    A member function is a function that can be defined either inside or outside the class definition and is a part of class and can not be accessible out side of the class without class object. But ordinary function is just like a normal function and can be access anywhere in the program freely.
  2. Differentiate between call by value & call by reference with a suitable example.
Call By Value Call By Reference
The formal argument holds a copy of the value of the actual argument.
The actual argument value cannot be changed by the function.
The actual argument can be a variable, a constant or an expression.
The formal argument is a reference of the actual argument.
The actual argument value can be changed by the function.
The actual argument must be a variable.

Example:-
Call by value:

#include<iostream.h>
void swap(int a,int b)
{
int c;
c = a;
a = b;
b = c;
}
void main( )
{
int x, y ;
cout<<”enter two no”;
cin>>a>>b;
cout<<”Before calling swap function value of x = “<<x<<endl;
cout<<”Before calling swap function value of y = “<<y<<endl;
swap(x,y);
cout<<”After calling swap function value of x = “<<x<<endl;
cout<<”After calling swap function value of x = “<<x<<endl;
}

Call by Reference:
#include<iostream.h>
void swap(int &a,int &b)
{
int c;
c = a;
a = b;
b = c;
}
void main( )
{
int x, y ;
cout<<”enter two no”;
cin>>a>>b;
cout<<”Before calling swap function value of x = “<<x<<endl;
cout<<”Before calling swap function value of y = “<<y<<endl;
swap(x,y);
cout<<”After calling swap function value of x = “<<x<<endl;
cout<<”After calling swap function value of x = “<<x<<endl; }

  1. Differentiate between global & local variable with a suitable example.

Ans: Local variable: The variables that have a local scope are known as local variables. In other words, variable that can used only in the function or the block where they can declared are known as local variable.
Global Variable: The variable that have a global scope are known as global variables. In other words, variables that can be used in all bocks and function in a program are known as global variables.

  1. Differentiate between nested class & inheritance with a suitable example.

Ans: The difference between nested class and inheritance is that in nesting class the class that contains an object of other class can access only the public members of that class private and protected members are not accessible to the enclosing class. But in inheritance derived class can access the protected members of the base class also.

  1. Differentiate between default & copy constructor with a suitable example.

Ans: Default Constructor: A default constructor is a constructor that has no parameters.
Copy Constructor: A copy constructor is a constructor that that initialises a new object with the value of an existing object.
class abc
{
int x,y;
public:
abc( )
{
x = 10;
y = 20;
}
abc(abc &t)
{
x = t.x;
y = t.y;
}
};

 

Previous Index Next

Submitted By Mr. Kapil Bhatia
Email Id : [email protected]