' Computer Science Basic Theory for CBSE Class XII Board Examination 2011 by Mr. Kapil Bhatia
Warning: include_once(../../../../../headder.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/papers/cbse_important_questions/xii/2011/computer_science/computer_science3.php on line 25

Warning: include_once(): Failed opening '../../../../../headder.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/papers/cbse_important_questions/xii/2011/computer_science/computer_science3.php on line 25

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

  1. What is the difference between macros and function?

Ans With Macros, a program runs faster as compared to functions. However, macros increase the program size a macros statement is replaced with its expansion wherever it is called. Whereas, functions occupy less memory space as the function call statement passes the program control to the function instead of replacing the call with the function body.

  1. Illustrate the use of #define in C++ to define a macro.

Ans #define preprocessor directive is used to define symbolic constant in a program. The #define identifier replacement is also known as a macro definition or simply a macro macros may be define with zero or more arguments. A macro without argument is used to define a symbolic constant and a macro with arguments is used to replace expressions or code fragments in a program. A macro define is not terminated by semicolon.
Example:
#define LIMIT 10 //Symbolic constant
#define sqr(x) (x*x) //Macro

  1. Define Multilevel & multiple inheritances in context of OOP with suitable example.

Ans: When one class is inherited from another class, which in turn is inherited from some other class, it is referred to as Multilevel Inheritance.

When a derived class inherits from more than one base class simultaneously, it is referred to as Multiple Inheritance.

  1. Illustrate the use of inline function in C++ with the help of a suitable example.

Ans: A inline function is a function whose code is copied in place of each function call. Inline functions are specified by prefixing the inline keyword to the return type in the function prototype. A function that is specified as inline ‘request’ the compiler to replace its each and every call by the code in its body.

  1. What is a default constructor? How does it differ from destructor?

Ans: Default Constructor: A default constructor is a constructor that has no parameters.
Destructor: A destructor is used to released the resources and the memory allocated to the data member when scope of the object terminates

  1. Differentiate between a date type struct & a data type class in C++.

Ans: The Differnce b/w class and structure is that by default all the members with in a class are private and with in a structure by default they are public:

  1. Explain the concept constructor overloading with a suitable example.

Ans: When multiple constructors are defined for a single class such constructors are referred to as overloaded constructor and the process is called constructor overloading.

  1. What do you understand by visibility modes in class derivations ? what are these modes.
  2. What do you understand by Syntax Error, logical Error & Run time error.

Ans: Syntax Error: Those error that comes at the time of compilation are known as syntax error like as statement terminator missing.
Logical Error: Logical errors occur due to wrong analysis of the program. Due to logical error program does not give the desired result.
Runtime Error: Those errors that comes during execution are known as run-time error. Example:

  1. Division by zero
  2. Stack over flow
  3. Array index out of bound
  1. What do you understand by enum?

Ans: The enumeration is a set of integer constant, written as identifiers, specifying the possible value that can be assigned to the enumeration variable. These set of possible values are known as enumerators. By default the first enumerator in the enumeration data type is assign the value zero.
Example:
enum color(red,green,blue};
cout<<blue;
Output 2

  1. Define Friend class?

Ans: Sometimes, member functions of one class require to access to the private members of another class. In such cases, the class that requires an access the private members of the other class can be made a friend of that class. A class that is made a friend of another class is known as friend class. Friend classes are declared with the keyword friend and class inside the class of which it is a friend.

Exp. #include<iostream.h>
class number
{
int value;
public:
friend class abc;
};
class abc
{
public:
void add(int x,int y)
{
number n1, n2;
n1.value = x;
n2.value = y;
cout<<(a1.value + n2.value)<<”\n”;
}
};
void main()
{
abc a;
a.add(10,20);
}

OUT PUT IS - 30

  1. Define Friend Function?

Ans: A friend function is a non member function of the class but function an access to all the private and public member of a class of which it is a friend. Friend function is declare with the friend keyword inside the class.
Exp. #include<iostream.h>
class para
{
int side1;
public:
int side2;
friend void per(int,int);
};
void per(int x, int y)
{
cout<<”Friend Function”;
para p;
p.side1 = x;
p.side2 = y;
cout<<” Value of side1=”<<p.side1<<endl;
cout<<”Value of side2=”<<p.side2<<endl;
}
void main()
{
per(10,20);
}
The output of the program is
Friend Function
Value of side1= 10
Value of side2= 20

  1. What do you understand by union?

Ans: Unions, like a structures, consist of members of the same data type or different data types. The only difference is that all the members of a union share common storage are, but in structure all the member assigned its own unique storage area.

  1. Define the term typedef with suitable example.

    Ans: The typedef keyword allows the programmers to define a new data types based on the existing data type. The typedef define a new name for an existing data type. Example: typedef int integer;

 

Previous Index Next

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


Warning: include(../../../../../120_60_others.php): Failed to open stream: No such file or directory in /home/cbseguess/public_html/papers/cbse_important_questions/xii/2011/computer_science/computer_science3.php on line 227

Warning: include(): Failed opening '../../../../../120_60_others.php' for inclusion (include_path='.:/opt/cpanel/ea-php83/root/usr/share/pear') in /home/cbseguess/public_html/papers/cbse_important_questions/xii/2011/computer_science/computer_science3.php on line 227