' Computer Science Basic Theory for CBSE Class XII Board Examination 2011 by Mr. Kapil Bhatia

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 1 of 7

  1. What do you understand by procedural programming paradigm?

    Ans: In the procedural Programming, program are divided into different procedures(also known as functions, routines or subroutines) and each procedure is a set of instruction is a set of instruction that performs a specific function.

  2. What do you understand by object oriented programming paradigm?

    Ans: In the Object Oriented Programming, programs are divided to represent real word models in a better way through object. The major concept in OOP includes objects, classes, encapsulation, abstraction, inheritance, and polymorphism.

  3. Explain all the features of OOPs with their implementation in C++.

    Encapsulation: Enapsulation refers to the grouping of data and function within a single entity. The data and function that are encapsulated together correspond to the properties and action of the real word object respectively.

    Data Hiding: The data defined in the class accessed only through the function defined in the class Thus, the data is hidden and safe from any accidental modification or deletion by the program. This protection of the data from the class is known as data hiding or information hiding.

    Inheritance: Inheritance refers to the means by which one class acquires or inherits the data and function of another class. It allows the new class to have the same data and function of the existing class and add other the data and function specific to the new class.

    Polymorphism: Polymorphism refers to the ability of an operation to function in different ways depending on the context. Polymorphism is implemented either at compile time or at runtime. Functions are overloaded when they are defined with the same name but different parameters lists. The parameter list of the function differs from that of another function when the number or the data types of the parameters of the two functions differ.

    Abstract Class: A class which provides only the interface of one or more functions and not their implementations is known as an abstract class. An abstract class only specifies what the function does, what all its requires, etc. but it does not specify to the new class.

    Concrete Class: The class that provides an implementation for all its function is known as concrete class. The concrete class can have one or more object.

  4. Why main function is so special in C++. Give at least two reasons.

    Ans: Whenever a C++ program is executed only the main function is executed. The execution of the program starts and end at main().

  5. Write two advantages of using #include complier directive.

    Ans: #include directive instruct the compiler to include the contents of the file enclosed within angular brackets into the source file.

  6. Differentiate between a run time error and syntax error. Give one example of each.
  7. Illustrate the concept of function overloading with the help of an example.

    Ans: Functions are overloaded when they are defined with the same name but different parameters lists. The parameter list of the function differs from that of another function when the number or the data types of the parameters of the two functions differ.
    void add(int a,int b);
    void add(int a,float b);
    void add(int a,char str[ ]);

  8. Why is a destructor function required in classes? Illustrate with the help of an example.

    Ans: Destructor function is required because the resources and the memory allocated to data members must be released when the sope of the object terminates.

  9. Illustrate the use of this pointer with the help if an example.

Ans: The this pointer is a special pointer that contains the address of an object of a class currently calling the member function of the class.
Ex. #include<iostream.h>
Class x
{
private:
int a;
public:
void setdata(int b)
{
a = b;
}
void print( )
{
cout<<”a=”<<a<<endl;
cout<<”\n The address of the calling object is :”<<this;
}
};

void main( )
{
x ob1;
int a = 10;
obi.setdata(a);
ob1.print( );
}

  1. What is the use of a constructor function in a class? Give a suitable example for a constructor function in a class.

Ans: A constructor is a special member function of a class that has the same name as that of the class and is automatically called when an object of the class is declared. It allows the object a class to be initialized in the same way as variables or built- in data types.
Example:
#include<iostream.h>
class abc
{
private:
int x;
public:
abc( ) //constructor function
{
x=10;
}
};
void main( )
{
abc a1;
}

 

Previous Index Next

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