Friday, October 27, 2017

C++ One Mark Question and Answer for BCA & B.Sc(IT) Students


--------------------------------------------------------------------------------------------------------------------------
Prepared By : Uday Shah - HOD(IT)
Mobile No : 7600044051
E-Mail : rupareleducation@gmail.com

Object Oriented Programming Using C++


1.       To perform the write operator on output device, c++ uses.
Ans : bit wise left-shift operator

2.       Which keyword is used to perform the write operation in c++.       
Ans : cout  

3.       ________ is derived data type.
          Ans : Array

4.       Symbol of scope resolution operator is.
          Ans :   ::

 5.      inline function we can use loop and nesting of if, statement is.
          Ans : False

6.       Function with constant argument, argument is declared as constant with _____keyword.
Ans : Const

7.       Which of the member can be access outside the body of the class.
          Ans : public

8.       object of the same class can be passed to the member function of the class by.
          Ans : Reference

9.       ____ is the member function which will be executed last, when the object is created.
Ans : Destructor

10.     Constructor must be explicitly invoked - the statement is.
Ans : False

11.     A unary operator member function takes ____ parameters.
          Ans : zero  



12.     Which of the following operator can not be overloaded?
          Ans : sizeof() , ternary           

13.     When a class is derived from another derived class  then it is called ______.     
Ans : Single Inheritance

14.     Which of the following is true in inheritance, when the object of the derived class is created.                
Ans : First the derived class is instantiated

15.     A virtual function with null body is called____.                                                 
Ans : Purer Virtual Function

16.     If instance of a class can be created then such class is called.                             
          Ans : Class or Simple Class

17.     ___ ios flag is used to print the decimal point and tralling zero.                                  
Ans : showbase

18.     getline()  is the function defined in ____ class.    
Ans : istream

19.     ____ mode is used to over write the file.                      
          Ans : app  (Append)

20.     In function template the function will be created at the time of.                
          Ans : some time at compile time and some time at execution time

21.     Which mechanism associates the code and data into a single unit and keeps them safe from external interference and misuse.
          Ans : Encapsulation

22.     in C ++ Main Function always return.      
          Ans : integer

23.     ____operator is used to release memory dynamically.
          Ans : Delete

24.     break statement will terminate the.
Ans : loop

25.     main() function consist ____ number of arguments.
Ans : Two   

26.     inline function is used when function having large body. Statement is.
Ans : False
           
27.     A function which can access the private member function outside the body of the class with the class with the help of object is called.
Ans : Friend Function   

28.    ___is the first member function which will be executed first, when the object is created.
          Ans : Constructor

29.     Which of the following is true for destructor.
          Ans : It may be declared under public section
           
30.     A binary operator member function takes___ parameters.
          Ans : one   

31.     Overload operator member function can never have default arguments? the statement is.
          Ans : True
           
32.     During dynamic memory allocation in CPP, new operator returns _________ value if memory allocation is unsuccessful.   
Ans : NULL

33.     A class become the base class for more then two derived class then it is called___.            
         Ans : Hierarchical inheritance  

 34.    Which symbol is used to declare a pointer variable.                                           
 Ans :  *               

 35.    General syntax of this pointer is.                                  
          Ans : extern classname *this 

36.     ___ios flag is used to print base of the numeric data.                                
          Ans : Showbase
         
37.     ___manipulator is put the \0 at the end of output stream.     
          Ans : ends 

38.     seekg (-n, ios::cur) moves the cursor.                  
          Ans : nth byte backward from the current position

39.     Which of the following is invalid in template.       
a) test <double, 6>5>;   b) test<double,(6>5); 
c) a & b both are valid   d) None of these

40.     Full form of AOP.
Ans : Aspect Oriented Programming      

41.     Creator of c++.    
          Ans : Bjarne Stroustrup       

42.     c++ identifier is also known as.
          Ans : keywords   and variable

43.     pick out non parameterized manipulator.
          Ans : setw  

44.     Function prototype is only declared for    
          Ans : compiler              

45.     main() function consist _____ number of arguments.
          Ans : int argc      

46.     Member function define out side the body of the class is by default becomes.
          a) inline                          b) outline                       c) friend      d) None

47.     A Pointer, which can point to any member of the class can created, the statement is.
          Ans : true
48.     A constructor without any parameter is called.
          Ans : Default constructor        

49.     The operator which operates on three operand is called ____.
Ans : Ternary Operator



50.     Which of the following operator can not be overloaded with friend function.
           Ans :  =  Assignment  , ()  Function call    , []  Subscript

51.     Which of the following is not the visibility mode.
          Ans : virtual       

52.     Derived class also referred as.
           Ans :  child class  and  sub class                       

53.     ____ pointer will be create when the member functions is invoked through the object.          
           Ans :  This            

54.     If instance of a class can not be created then such class is called.                                     Ans : Abstract Class

55.     To flushes all the stream ____ ios flag isused.                                          
Ans :  stdio          

56.     _____ ios flag is used  to print the sign before the fill character.                                  
          Ans : left   

57.     tellg() is the member function of _____ class.     
          Ans : ifstream     

58.     pick out non parameterized manipulator.
          Ans : setw           

59.     Function prototype is only declared for    
Ans : compiler              

60.     main() function consist _____ number of arguments.
Ans : char ** envp      

61.     Member function define out side the body of the class is by default becomes.
Ans : Outline       

62.     Can constructors be overloaded?
Ans : Yes

63.    When overloading unary operators using Friend function,it requires_____ argument/s.
Ans : One 

64.    In CPP program, Can we declare and define a user defined function inside a struct as we do in a class ?
Ans : Yes

65.     Runtime polymorphism is achieved only when a virtual function is accessed through a pointer to the base class.
Ans : True

66.     Assigning one or more function body to the same name is called ____________ .
          Ans : Function Overloading

67.    Function overloading can also be achieved if two or more functions differ only in their return types.
          Ans : False

68.    A function can be declared as friend maximum only in two classes.
          Ans : False

69.    When a child class inherits traits from more than one parent class, this type of inheritance is called _______________ inheritance.
          Ans : Multiple.

70.     __________________ is the OOP feature and mechanism that binds together code and the data it manipulates, and keep both safe from outside world.
          Ans : Data Encapsulation

71.    We can create objects of the abstract class.
          Ans : False

72.    Which of the followings are true about Virtual functions?
          They must be non-static member function of the class
Ans : They cannot be friends
         Constructor Functions cannot be virtual

73.    If a class contains static variable, then every object of the class has its copy of static variable.
          Ans : False
74.    In Multipath inheritance, in order to remove duplicate set of records in child class, we ___________ .
          Ans : Make base class as virtual base class

75.     If base class has constructor with arguments, then it is ________________ for the derived class to have constructor and pass the arguments to base class constructor.
          Ans : Mandatory

76.    An operator function is created using _____________ keyword.
          Ans : Operator

77.    Classes in CPP are________ .
          Ans : User defined data types

78.    Can we define our exceptions in CPP?
          Ans : Yes

79.    The code of statements which may cause abnormal termination of the program should be written under_________ block.
          Ans : Try

80.    When a virtual function is redefined by the derived class, it is called___________.
          Ans : Overriding

81.    In any ways, Non-member function cannot have access to the private data of the class.
          Ans : False

82.    In CPP, dynamic memory allocation is done using ______________ operator.
          Ans : New

83.    Can we allocate memory for the objects dynamically in CPP?
          Ans : Yes

84.    If the derived class is struct, then default visibility mode is _______ .
          Ans : Public

85.     ___________ header file is used for manipulators.
          Ans : iomanip.h
86.    const member function does not allow to modify/alter value of any data member of the class.
          Ans : True

87.    Can struct be used as Base class for inheritance ?
          Ans : Yes

88.    Is it possible to define a constructor with default arguments?
          Ans : Yes

89.    The purpose of explicit keyword is to tell the compiler that a certain constructor may not be used to implicitly cast an expression to its class type.
          Ans : True

90.     Scope resolution operator is used______ .
          Ans :  to resolve scope of global variables as well as functions of the classes

91.    A try block can be nested under another try block.
          Ans : True

92.    We can prevent a function from throwing any exceptions.
          Ans : True

93.    Functions called from within a try block may also throw exception.
          Ans : True

94.    The explicit keyword is an optional decoration for the constructors that takes exactly_____argument.
          Ans : One

95.    A class can contain objects of other classes and this phenomenon is called_________ .
          Ans : Containership

96.    Can we alter/modify the values of data members of a class inside const member function?
          Ans : Yes

97.    If a class contains pure virtual function, then it is termed as____________________ .
          Ans : Abstract Class

98.     If inner catch handler is not able to handle the exception then__________ .
          Ans : Compiler will check for appropriate catch handler of outer try block

99.    In CPP program, Can we declare and define a user defined function inside a struct as we do in a class ?
          Ans : Yes

100.   ____________ refers to the act of representing only essential features without including the background details.
          Ans : Data Abstraction


101.    Generic pointers can be declared with__________ .
          Ans : Void

102.   A Constructor that does not have any parameters is called____________ Constructor.
          Ans : Default

103.    _______________ is a member function that is declared within a base class and redefined by derived class.
          Ans : Virtual Function

104.   Syntax for Pure Virtual Function is ______________ .
          Ans :  virtual void show()=0

105.     Logical expressions produce ____________ type results.
          Ans : Bool

106.      A friend function does not have 'this' pointer associated with it.
          Ans : True

107.   In CPP, it is mandatory and must to initialize const variables.
          Ans : True

108.     A virtual function that has no definition within the base class is called____________.
          Ans : Pure virtual function

109.     Constant variables can be created in CPP by using ________ .
            Ans : Enum , Const , #define

110.   In CPP, cin and cout are the predefined stream __________ .
          Ans : Objects

111.     _________________are used for generic programming.
          Ans :  Templates


Best Of Luck

Please give your comment and share it...

Monday, October 2, 2017

Object Oriented Programming Using C++ Chapter No : 11 & 12 for BCA and BSc(IT) Studetns


--------------------------------------------------------------------------------------------------------------------------
Prepared By : Uday Shah (HOD - IT)
Mobile No : 7600044051
E-Mail : rupareleducation@gmail.com


Chapter 11
Que.    Exception Handling:
Ans.     A program execution may return an abnormal unexpected error at run time which cause the program to fail such errors are known as exceptions. Exceptions are different from logical errors. Which occurs due to poor understanding. Of problems and solution procedure. Exceptions are only checked at run time only.
Following are some exceptions which occurs during the program executions are:
1.                  Divide by zero.
2.                  NULL pointer assignment.
3.                  Stack overflow.
4.                  Low memory space.
5.                  Array out of bound.
6.                  Arithmetic overflow etc…
Are such errors which return and exception in a program. The error handling mechanism of C++ is generally refer to as a exception handling. Exception handling is the part of ANSI/ISO. C++ provide a building language features to detect and handle exception occurs a specially at run time. Exceptions are classified into.
           
Synchronize Exceptions and Asynchronies Exceptions.

The synchronize exceptions are occurs during the program execution due to some fault in the part of input data. While asynchronies exceptions occurs by events or some external program which work inside the program execution it may occurs also hardware failure, system failure etc… Exception handling mechanism provide a way to handle run time error. The exception handling mechanism perform following task. That is…
1.                  Find the problem.
2.                  Inform that an error has occurs.
3.                  Receive the error information.
4.                  Take corrective action.

Que.    Exception Handling model.
Ans.     When program encounter and abnormal situation at run time when it transfer control to some other part of the program that is… design to deal with the program and this is done by throwing an exception. The exception handling mechanism use three blocks. That is…
            (1) try              (2) throw         (3) catch
Following is a model of error handling.
            try
           

throw


            catch

The try block must be follow immediately by the handler. The catch block is working as a exception handler. Try block contain all the code which may occur error during program running and may generate run time errors and if error occurred then catch block handle error and program going  to be very smooth.  



Chapter 12.
STL Standard Template Library

Que.    Introduction of Template
Ans.                 C++ support many kind of datatype that may be basic datatype, derived datatype, user define datatype and there are many requirements in which we have to write the same function with different datatypes.
The main benefit of object oriented programming is reusability of code which eliminate the redundant code.
The advantage features of C++ call template allow defining a single function for different datatypes.
Templates are mechanism that makes it possible to use one function or a class to handle many different datatype.
Template support generic programming where designs a single class or function that operates on data of many types. Instant of creating a separate class or function for each type. When template use with function they are known as function template where as when use with class they are call class template.
Template is serve as a one kind of macro. The template definition for the specific class is replace with the require datatype.
When template define as a parameterize template give the ability to create generic class and pass datatype as a parameter to that class.

Que.    Function Template
Ans.     The function template define a general set of operation that will be apply to various types of data it is also known as generic function. Through a generic function a single general procedure can be applied to different datatype in a function. Following is syntax of function template:
Template<class t1, classt2, ...>
return_type function_name(argument list)
{
body of the template function.
}
According to above syntax:    Function template is prefix with the keyword template with the list of template parameter. This template type argument are call generic datatype. The syntax of function template is similar to normal function. But the variable in the function template declare not know until a call to it.

Que.    Class template
Ans.     Class can also be declare to operate on different datatype such class are call class template. It specify a generic class which use logic that can be generalize.
For ex: The same class that maintain int type data, float type data etc... it allow to create class template. The syntax to create class template is as follow.
Template<class t1, t2, ... >
Class class_name
{
Datatype t1,t2, ... ;
                        Body of the class template
}
According to above syntax:    The keyword template is use as the beginning of every declaration and definition of template class. The parameter of the template are written after the template keyword. It will change with each instance to call by template class. To create object using class template use following syntax:
class_name<datatype> object_name;
According to above syntax:    here class name is the name of the class specification in a template class. Which has all the members with type datatype and associated by object name.

Que.    Class template with multiple parameter.
Ans.     It is possible to use more than one generic datatype in a class template. For that we have to declare a class template with comma separated list within the template specification.

Que.    Member function template.
Ans.     When design any member function inside class specification it became inline function to design any member function outside the class. The member function of the template allow to declare a parameterize by the type argument and it implicitly treated as a template function.

Que.    Overloading template function.
Ans.     Similar to normal function template function can also be overloaded. It may be overloaded either by other function or its name or by other template function of the same. In overloaded template function number of parameters and types of parameter should be different.

Que.    Non Type template argument.
Ans.     A template can have multiple arguments in the template specification for a generic class. It is also possible to specify non-type template arguments. It is addition to the type argument to another non-type argument may be either or following.
           
int, string, function_name, constant expression and buil in type.

Que.    Primary and partial specialization.
Ans.     When you create a class template the compiler a create a definition based on the template arguments that you have pass. Alternatively if all those template arguments match with an explicit argument then compiler use the definition of explicit specialization. A partial specialization generalization of an explicit specialization. An explicit specialization only has a template argument list. A partial specialization has both a template argument list and non-template argument list. At that time compiler will generate a new definition for template argument list.

Que.    Intro to STL (Standard Template Library).
Ans.     STL means Standard Template Library. The standard library is fundamental part of the C++. It provide C++ programs with a comprehensive set of effectively and efficient implemented tools and facility that can be use for most types of applications. Standard template library contain mainly three components that is...
1.      Algorithms
2.      Containers
3.      Iterators(Looping)
STL is a generic library it means container or algorithm can be operated on any datatype. You don’t have to be define. The same algorithm for different type of elements.
1.      Algorithm:
STL provide numbers of algorithm that can be use of any container or their types. Algorithm library contain build in functions that perform complex algorithm on data structure.
2.      Container:
Container library in SIL provide containers that are use to create data structure like. Array, linklist, tree etc...
This containers are generic they can hold elements of any datatype.
3.      Iterators:

It is used to point the container. It is act as a bridge between containers and algorithms.