Tuesday, October 1, 2013

Question Papers

A10.1-R3: INTRODUCTION TO OBJECT ORIENTED PROGRAMMING AND C++


NOTE:
1.         There are TWO PARTS in this Module/paper. PART ONE contains FOUR questions and PART TWO contains FOUR questions.

2.         PART ONE is to be answered in the TEAR-OFFANSWER SHEET only, attached to the question paper, as per the instructions contained therein. PART ONE is NOT to be answered in the answer book.

3.         Maximum time allotted for PART ONE is ONE HOUR. Answer book for PART TWO will be supplied at the table when the answer sheet for PART ONE is returned. However, candidates who complete PART ONE earlier than one hour, can collect the answer book for PART TWO immediately after handing over the answer sheet for PART ONE.

TOTAL TIME: 3 HOURS                                                                                 TOTAL MARKS: 100

    (PART ONE-40; PART TWO – 60)

PART ONE

(Answer all the questions)

1.         Each question below gives a multiple choice of answers. Choose the most appropriate one and enter in the “tear-off” answer sheet attached to the question paper, following instructions therein.                                                                                                          (1 x 10)

1.1       Which of the following would be an invalid class declaration header for a derived class d, with base classes b1 and b2?
A)         class d: public b2, public b1
B)         class d: class b2, class b1
C)        class d: public b2, b1
D)        class d: b2,b1

1.2       A class hierarchy
A)         shows the same relationship as an organization chart
B)         describe “ has a” relationship
C)        describe “is a kind of” relationship
D)        shows the same relationships as a family tree.

1.3       An array element is accessed using
A)         A FIFO approach
B)         the operator
C)        a member Name
D)        An index number

1.4       When a language has the capability to produce new data types, it is said to be a
A)         reprehensible
B)         encapsulated
C)        overloaded
D)        extensible
  
1.5       The new operator
A)         returns a pointer to a variable
B)         creates a variable called new
C)        obtains memory for a new variable
D)        tells how much memory is available

1.6       A copy constructor is invoked when
A)         a function returns by value
B)         an argument is passed by value
C)        a function returns by reference
D)        an argument is passed by reference

1.7       A friend function can be used to
A)         avoid arguments between classes
B)         allow access to classes whose source code is unavailable
C)        allow one class to access an unrelated class
D)        Increase the reusability of an overloaded operator

1.8       A default argument has value, that
A)         may be supplied by the calling program
B)         may be supplied by the function
C)        must have constant value
D)        must have a variable value

1.9       The break statement causes an exit
A)         only from the innermost loop
B)         only from the outermost loop
C)        from all loops and switches
D)        from the innermost loop and switch

1.10     How many constructors can a class have?
A)         0
B)         1
C)        2
D)        any number

2.         Each statement below is either TRUE or FALSE. Choose the most appropriate one and ENTER in the “tear-off” sheet attached to the question paper, following instructions therein.                                                                                                                      (1 x 10)
 2.1       A variable can be tied with several references.
2.2       It is possible to create an array references.
2.3       Object oriented programming language permit functional and data abstraction.
2.4       A pointer to a base class can point to the objects of a derived class.
2.5       A copy constructor could be defined to copy only part of an object is data.
2.6       Scope Resolution Operator (::) could be overloaded in C++.
2.7       Pure virtual function can never have a body.
2.8       A friend function can access a class’s private data without being a member of the class.
2.9       Private members of the base class can be accessed by derived class members’ function/objects of derived class.
2.10     The exception handling mechanism is supposed to handle compile time errors.

3.         Match words and phrases in column X with the closest related meaning/ word(s)/phrases in column Y. Enter your selection in the “tear-off” answer sheet attached to the question paper, following instructions therein.                         (1 x 10)

                        X                                                                                  Y
3.1
An abstract class
A.
is used to access a member when we use pointers to both the object and member
3.2
Exception
B.
is one that is not used to create objects
3.3
Derived class
C.
can be used to combine similar function into one
3.4
Protected
D.
makes a program run faster
3.5
Scope resolution Operator
E.
is runtime anomalies that a program may encounter while executing
3.6
Inline function
F.
inherits data members and member functions from their base classes.
3.7
Constructor
G.
is a visibility modifier
3.8
Object
H.
is a basic run time entity in an Object-Oriented System
3.9
Default arguments
I.
is a process of binding of data and functions together into a single class-type variable
3.10
Encapsulation
J.
may contain any number of arguments


K.
is a process of making an operator to exhibit different behaviors in different instances


L.
can not be overloaded
 4.         Each statement below has blank space to fit one of the word(s) or phrases in the list below. Enter your choice in the “tear-off” answer sheet attached to the question paper, following instructions therein.                                                                       (1 x 10)

A.
inheritance
B.
protected
C.
polymorphism
D.
destructor
E.
exception
F.
template
G.
private
H.
inline
I.
derived
J.
friend
K.
constructor
L.
encapsulation
M.
protected
N.
destructor
O.
object

4.1       ____________ function is similar to #define macros.
4.2       ____________ is a process of creating new classes from an existing class.
4.3       Bundling of data and functions together is called _____________.
4.4       The ________ is a special member function for automatic initialization of an object.
4.5       _______ is used to design a single class/function that operates on the data of many types instead to create a separate class/function for each type.
4.6       _________ refers to any unusual condition in a program. It is used to notify error to a caller.
4.7       A(n) _________ class can access private members of another class.
4.8       To be accessed from a member function of the derived class, data or functions in the class must be public or __________.
4.9       The ability of a function or operator act in different ways on different types is called ___________.
4.10     The ___________ is used to de-allocate memory that was allocated for an object.

PART TWO
(Answer any FOUR questions)
 5.
a)         What is polymorphism? How can we achieve compile time and run-time polymorphism?
b)         Define a class for date with three variables for day, month, year and functions for getting data and displaying data on the screen. Write constructors with and without arguments for the class and destructor that sets values to zero for all three variables. Define object of the class in main and call the write functions using this object.
(5+10)
 6.
a)         Explain with example a template class.
b)         What is meant by exceptions? How an exception is handled in C++? Bring out the advantages of using various exceptions handling mechanism.
c)         What do you mean by overloading of a function? When do we use this concept?
(5+5+5)

7.
a)         Describe the basic concepts of Object Oriented Programming and bring out the advantages of OOP.
b)         Write down characteristics of friend function and constructor.
c)         Why virtual function is required? Explain with suitable example.
5+5+5)

8.
a)         Write a program-using pointer to copy all the characters from string s1 to string s2.
b)         What is memory leakage? Suggest and implement an approach to trace memory leakage.
c)         How do you create an abstract class? Explain it with example.
(5+5+5)
 9.
a)         Explain the significance of friend function and friend class with proper example. Also explain how a friend function behaves like a bridge between two classes?
b)         Explain pointer with suitable example.
c)         Differentiate between structure and class?
d)         What is containership and how does it differ from inheritance?

(5+3+4+3)

INTRODUCTION TO OBJECT ORIENTED PROGRAMMING AND C++


NOTE:
1.         There are TWO PARTS in this Module/paper. PART ONE contains FOUR questions and PART TWO contains FOUR questions.

2.         PART ONE is to be answered in the TEAR-OFFANSWER SHEET only, attached to the question paper, as per the instructions contained therein. PART ONE is NOT to be answered in the answer book.

3.         Maximum time allotted for PART ONE is ONE HOUR. Answer book for PART TWO will be supplied at the table when the answer sheet for PART ONE is returned. However, candidates who complete PART ONE earlier than one hour, can collect the answer book for PART TWO immediately after handing over the answer sheet for PART ONE.

TOTAL TIME: 3 HOURS                                                                                 TOTAL MARKS: 100    (PART ONE-40; PART TWO – 60)

PART ONE
(Answer all the questions)

1.         Each question below gives a multiple choice of answers. Choose the most appropriate one and enter in the “tear-off” answer sheet attached to the question paper, following instructions therein.             (1 x 10)

1.1       Which members of a base class are inherited by a subclass?
A)         All the public and private members.
B)         All the protected and private members.
C)        All the public and protected members.
D)        None of the above.

1.2       Assume that a class XYZ contains a static data member x. How many copies of the variable x exist if 4 instances of the class XYZ are created?
A)         0
B)         1
C)        4
D)        None of the above

1.3       Which of the following statements is FALSE in view of a copy constructor?
A)         It requires one parameter, which has the same class as that being declared and it must be passed by constant reference.
B)         If a class definition does not explicitly include a copy constructor, then the system automatically creates one by default.
C)        When a copy constructor is called, its copies the complete state of an existing object into a new object of the same class.
D)        None of the above.

1.4       Assuming that p is a pointer to an object of a class X containing public integer data member data1, which of the following statements is TUE?
A)         *p.data1=100;              is equivalent to             p->data1=100;
B)         (*p).data1=100;            is equivalent to             p->data1=100;
C)        p.data1=100;                is equivalent to             (*p)->data1=100;
D)        None of the above

1.5       How many destructors can a class have?
A)         0
B)         1
C)        2
D)        None of the above

1.6       Which of the following ‘C++’ types, is not a derived type?
A)         enumeration types
B)         pointers
C)        arrays
D)        none of the above

1.7       Identify an illegal declaration of a reference from the following ‘C++’ statements.
A)         int&      r = 82;
B)         int&      r = n;
C)        int&      r = a[5];
D)        None of the above

1.8       Which of the following statements is TRUE?
A)         The iostream class is a subclass of the fstream class.
B)         The iostream class is a subclass of both the istream class and the ostream class.
C)        The iostream class is a subclass of the ifstream class.
D)        None of the above.

1.9       Which of the following functions is NOT a member function of the input stream object cin?
A)         Getline( )
B)         ignore( )
C)        putback( )
D)        none of the above

1.10     Which of the following ‘Visual C++’ tools is a program that is accessible from Visual C++’s View Menu to generate prototypes and function bodies for message handlers?
A)         Resource editors
B)         AppWizard
C)        ClassWizard
D)        None of the above

2.         Each statement below is either TRUE or FALSE. Choose the most appropriate one and ENTER in the “tear-off” sheet attached to the question paper, following instructions therein.                                                                                                                      (1 x 10)

2.1       Each class can have exactly one constructor.
2.2       The only member functions that can be called for const objects are constructors and a destructor.
2.3       A pointer to a constant can be deleted using the delete operator.
2.4       Subclasses can access private members of a parent class but not protected members.
2.5       Private members of a class are accessible only from within the class itself and its friend classes.
2.6       When an array has an explicit initialisation, its size specifies may be omitted from its declaration.
2.7       Symbolic constants are not values because they cannot appear on the left side of an assignment.
2.8       An index variable for ‘C++’ array may run far beyond its defined range without any error being detected by the computer.
2.9       The new operator always returns a void pointer.
2.10     Multiple line comments in ‘C++’ require three asterisks on each line.

3.         Match words and phrases in column X with the closest related meaning/ word(s)/phrases in column Y. Enter your selection in the “tear-off” answer sheet attached to the question paper, following instructions therein.                         (1 x 10)

            X                                                                                  Y
3.1
constructer
A.
defined in
3.2
abstract base class
B.
defined in
3.3
ends
C.
defined in
3.4
toupper( )
D.
achieved using virtual functions
3.5
overloaded assignment operator
E.
member function operator=
3.6
ostream
F.
pointer to the owner object
3.7
polymorphism
G.
has one or more pure virtual member functions
3.8
*this
H.
achieved using friend functions
3.9
encapsulation
I.
project file created by Visual C++
3.10
file extension DSP
J.
has no return type


K.
returns void


L.
bundling of data and functions


M.
stream manipulator


N.
image file created by Visual C++

4.         Each statement below has blank space to fit one of the word(s) or phrases in the list below. Enter your choice in the “tear-off” answer sheet attached to the question paper, following instructions therein.                                                                       (1 x 10)

A.
friend
B.
structure
C.
class
D.
ios
E.
iostream
F.
delete
G.
static
H.
cin.putback( )
I.
cin.pushback( )
J.
ifstream
K.
constructors
L.
destructors
M.
strlast(s, 's')
N.
ios:: skipleft
O.
GenCode
P.
strrchr(s, 's')
Q.
ios:: skipws
R.
AppWizard

4.1       The _________ function restores the last character read by a cin.get( ) back to the input stream cin.
4.2       The call _________ returns a pointer to the last occurrence of the character ‘s’ within the string s.
4.3       The default access specifier for data members of a(n) _________ is public.
4.4       _________ function members can be called before any objects are instantiated.
4.5       The _________ operator should only be applied to pointers that have been allocated explicitly by the new operator.
4.6       A(n) _________ function is a nonmember function that is given access to all members of the class within which it is declared.
4.7       The istream and ostream classes both inherit from the _________ class.
4.8       The _________ format flag is used to skip leading white space during formatted input.
4.9       _________ cannot be declared virtual.
4.10     _________ is a code generator that creates a working skeleton of a Windows application.
  
PART TWO
(Answer any FOUR questions)

5.         define a class named List to manipulate a list of integers. Include data members in the List class for holding an array of integers, storing the dimension of the array and keeping track of the actual number of elements in the array. Design a constructor, a destructor, a member function put_elem( ) that copies a given element at a specified position in the list, a member function get_elem( ) that retrieves a list element from the specified position in the list, a member function print( ) to print the content of the list in the original order, a member function reverse_print( ) to print the content of the list in the reverse order, member functions getn( ) and setn( ) to get and set the data member keeping track of the actual number of elements in the list. Invoke these member functions in the main( ) module to test them with suitable data.                            (15)

6.         Explain the meaning of polymorphism. Describe how polymorphism is accomplished in ‘C++’ taking a suit example?                                                                                                                      (15)

7.         What are friend functions? Explain how they are declared and used in a ‘C++’ program, taking a suitable example?                                                                                                                  (15)
 8.         Explain the major features of Object Oriented Programming (OOP) with example. How does OOP differ from traditional programming?                                                                                       (15)
9.         Define a class Fract whose objects represent rational numbers (i.e. fractions). Include integer data members numr and denr for storing a numerator and a denominator respectively. Provide a constructor and member function eval_fract( ) for evaluating the value of the rational number, invert( ) for inverting the given rational number, print( ) for printing the rational number in the form numr/denr (For example, 22 / 7). Also provide access functions get_numerator( ) and get_denominator( ) for returning the values of the private data members. Include a member function reduce_fract( ) that reduces the fraction numr/denr to lowest term. For example, the fraction 54 /90 is stored as the object 3 / 5. Invoke these member functions in the main( ) module to test them with suitable data.                                                                                              (15)
 

 INTRODUCTION TO OBJECT ORIENTED PROGRAMMING AND C++

 NOTE:
1.         There are TWO PARTS in this Module/paper. PART ONE contains FOUR questions and PART TWO contains FOUR questions.

2.         PART ONE is to be answered in the TEAR-OFFANSWER SHEET only, attached to the question paper, as per the instructions contained therein. PART ONE is NOT to be answered in the answer book.

3.         Maximum time allotted for PART ONE is ONE HOUR. Answer book for PART TWO will be supplied at the table when the answer sheet for PART ONE is returned. However, candidates who complete PART ONE earlier than one hour, can collect the answer book for PART TWO immediately after handing over the answer sheet for PART ONE.

TOTAL TIME: 3 HOURS                                                                                 TOTAL MARKS: 100    (PART ONE-40; PART TWO – 60)

PART ONE
(Answer all the questions)
1.         Each question below gives a multiple choice of answers. Choose the most appropriate one and enter in the “tear-off” answer sheet attached to the question paper, following instructions therein.              (1 x 10)

1.1       In C++, a function contained within a class is called
A)         a member function
B)         an operation
C)        a class function
D)        a method

1.2       Consider the following statements:
            int x = 22, y = 15;
      x = (x
            What will be the value of x after executing these statements?
A)         22
B)         37
C)        7
D)        Error. Cannot be executed.

1.3       The main( ) function returns value of type
A)         real
B)         character
C)        int
D)        null

1.4       The library function exit() causes an exit from
A)         the loop in which it occurs.
B)         the block in which it occurs.
C)        the function in which it occurs
D)        the program in which it occurs.
  
1.5       Which of the following is good reason the use an object-oriented language?
A)         It’s easier to conceptualize an object-oriented program.
B)         Program statements are simpler than in procedural languages.
C)        An object-oriented program can be taught to correct its own error.
D)        None of these

1.6       What would be the output fo the following program?
                        int main( )
                        {
            int x, y=10,z=10;
            x=(y==z);
cout<
return 0; }
A)         0
B)         1
C)        10
D)        error

1.7       When the break statement in encountered inside a loop, which one of the following occurs?
A)         control goes to the end of the program
B)         control leaves the function that contains the loop
C)        causes an exit from the innermost loop containing it
D)        causes an exit from all the nested loop

1.8       The friend functions are used in situations where
A)         we want to have access to unrelated classes
B)         dynamic biding is required
C)        we want to exchange data between classes
D)        none of these

1.9       An exception is caused by
A)         a hardware problem
B)         a problem in the operating system
C)        a syntax error
D)        a run time error

1.10     A template class

A)         is designed to be stored in different containers
B)         works with different data types
C)        generate objects which must all be identical
D)        generates classes with different numbers of member functions

 2.         Each statement below is either TRUE or FALSE. Choose the most appropriate one and ENTER in the “tear-off” sheet attached to the question paper, following instructions therein.                                                                                                                      (1 x 10)

2.1       In a 32-bit system, the data types float and long occupy the same number of bytes.
2.2       Only when an argument has been initialized to zero value, it is called the default argument.
2.3       When calling a function, if the arguments are passed by reference, the function works with the actual variables in the calling program.
2.4       The precedence of an operator can be changed by overloading it.
2.5       A pointer to a base class can point to an object of a derived class of that base class.
2.6       A derived class is often called a subclass because it represents a subset of its base class.
2.7       All functions in an abstract base class must be declared pure virtual.
2.8       An exception is always caused by a syntax error.
2.9       A function template can have more than one template argument.
2.10     The expression for(;;) is the same as a while loop with a test expression of true.

3.         Match words and phrases in column X with the closest related meaning/ word(s)/phrases in column Y. Enter your selection in the “tear-off” answer sheet attached to the question paper, following instructions therein.                         (1 x 10)

                        X                                                                                  Y
3.1
The operator stops reading a string when a space is encounter
A.
<< 
3.2
Rules that governs the construction of statement
B.
late binding
3.3
A data type that holds the address of a location in memory
C.
syntax
3.4
The addresses of the functions are determined at run time
D.
operator
3.5
A symbol that represents an action to be performed
E.
pointer to the owner object
3.6
A value, variable or expression that selects a particular element of an array
F.
>> 
3.7
The visible methods of an object
G.
stream manipulator
3.8
A source from which input data can be obtained or a destination to which output data can be sent
H.
parameter
3.9
A function that although not a member of a class is able to access the private members of that class
I.
friend
3.10
A short piece of text, or text template that can be expanded into a longer text
J.
Macro


K.
index


L.
interface


4.         Each statement below has blank space to fit one of the word(s) or phrases in the list below. Enter your choice in the “tear-off” answer sheet attached to the question paper, following instructions therein.                                                                       (1 x 10)

A.
overridden
B.
ios
C.
polymorphism
D.
static
E.
break
F.
class library
G.
reference
H.
multiple inheritance
I.
exit
J.
overloading
K.
multilevel inheritance
L.
conio.h

4.1       A(n) _______ statement is used to cause an exit from the loop and switch statements.
4.2       ___________ allows a derived class to have more than one base class.
4.3       When a virtual function is redefined in a derived class, it is said to be ___________.
4.4       A(n) _______ parameter automatically receives the address of its corresponding argument.
4.5       A group of related classes, supplied as a separate product, is often called a ___________.
4.6       A constructor cannot be declared as ___________.
4.7       The ability of a function or operator to act in different ways on different data types is called ___________.
4.8       The base class for most stream classes is the _________ class.
4.9       getch( ) is defined in _______.
4.10     A language feature that allows a function or operator to be given more than one definition is known _______.
PART TWO
(Answer any FOUR questions)
5.
a)         Distinguish between procedure-oriented programming and object-oriented programming.
b)         What is the main advantage of passing arguments by reference? Explain this with an example.
c)         What do you mean by Virtual Base Class?
(4+7+4)
 6.
a)         Why do we need to use constructors?
b)         Distinguish between overloaded functions and function templates.
c)         What does this pointer point to? Explain.
(5+5+5)
 7.
a)         Explain the concept of operator overloading. Illustrate operator-overloading concept to concatenate strings.
b)         How is polymorphism achieved at run time? Explain with coding.
(8+7)

8.         Imagine a publishing company that markets both book and audiocassette version to its works. Create a class publication that stores that title (a string) and price (type float) of a publication. Form this class derive two classes: book, which adds a page count (type int); and tape, which adds a playing tome in minutes (type float). Each class should has a getdata( ) function to gets its data from the user at the keyboard, and a putdata( ) function to display its data.
Write a main( ) program to test the book and tape classes by creating instances of them, asking the user to fill in data with getdata( ), and than displaying the data with putdata( ).
(15)
 9.         Write short notes on any three:
a)         Benefits of OOP
b)         Scope Resolution Operator
c)         Exception Handling
d)         cin vs getline function
(5x3)



          B2.51-R3: INTRODUCTION TO OBJECT ORIENTED PROGRAMMING AND C++
NOTE:
1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions
and PART TWO contains FIVE questions.
2. PART ONE is to be answered in the TEAR-OFF ANSWER SHEET only, attached to
the question paper, as per the instructions contained therein. PART ONE is NOT to
be answered in the answer book.
3. Maximum time allotted for PART ONE is ONE HOUR. Answer book for PART TWO
will be supplied at the table when the answer sheet for PART ONE is returned.
However, candidates, who complete PART ONE earlier than one hour, can collect the
answer book for PART TWO immediately after handing over the answer sheet for
                                                              PART ONE.
TOTAL TIME: 3 HOURS                                                                   TOTAL MARKS: 100
(PART ONE – 40; PART TWO – 60)
(Answer all the questions)
1. Each question below gives a multiple choice of answers. Choose the most
appropriate one and enter in the “tear-off” answer sheet attached to the question
paper, following instructions therein. (1 x 10)
1.1 In C++ the index of an array starts with
A) Any negative value.
B) Any positive value.
C) Value 1.
D) Value 0.
1.2 #include is a
A) Compiler statement
B) Debugging statement
C) Pre-processor statement
D) None of the above
1.3 Inline function acts as a
A) Function
B) Macro
C) Operator
D) Manipulator
1.4 Free store operators is (are)
A) :: (double colon)
B) & (ampersand)
C) * (star)
D) new, delete
1.5 ios represents
A) A class member function
B) A constant object
C) A stream
D) A base class
B2.51-R3 Page 1 of 5 January, 2006
1.6 A global variable declaration is made
A) Only in main function
B) Only in functions other than main function
C) Only outside functions
D) None of the above
1.7 A class can have
A) Only one constructor
B) Any number of constructors
C) Same number of constructors as the number of data members
D) None of the above
1.8 A function with variable number of arguments
A) Have only one prototype declaration
B) Should have as many as prototype declaration to be used to actual functions used with
different parameters
C) No prototype of the function required
D) None of the above
1.9 The break statement is used
A) To exit from the function in which it is used
B) To exit from the program
C) To exit from the loop in which it is used
D) To exit from all the nested loops
1.10 In overloading an operator we can use
A) To create a new operator
B) To overload the conditional operator, a ternary operator
C) Only to overload unary operator
D) To overload the unary as well as binary operator
B2.51-R3 Page 2 of 5 January, 2006
2. Each statement below is either TRUE or FALSE. Choose the most appropriate one
and ENTER in the “tear-off” sheet attached to the question paper, following
instructions therein. (1 x 10)
2.1 Structures in C++ cannot have member functions.
2.2 Objects cannot be declared as part of a union element.
2.3 Friend functions cannot be used to overload operators.
2.4 A constructor can be used to convert a basic type to a class type data.
2.5 Casting operator function and constructor function have the same syntax.
2.6 Pure virtual functions force the programmer to redefine the virtual function.
2.7 A pointer to a base class cannot be made to point to objects of derived class.
2.8 A stream may be connected to more than one file at a time.
2.9 Binary files store floating-point values more accurately and compactly than the text files.
2.10 An exception handling mechanism is used to detecting syntax errors in the program.
3. Match words and phrases in column X with the closest related meaning/
word(s)/phrase(s) in column Y. Enter your selection in the “tear-off” answer sheet
attached to the question paper, following instructions therein. (1 x 10)
X Y
3.1 All members share the same memory A. function template
3.2 Enclose a code raising an exception B. public
3.3 To construct a family of functions, what we use? C. volatile
3.4 To enhance an existing data types, a statement is
used
D. enum
3.5 To determine the number of bytes used by the
variable
E. constructor
3.6 Members accessible to all users F. virtual
3.7 Every reference to the variable will reload the
contents from memory, rather than can take
advantage of situations where a register is
allocated to the variable for efficiency purpose.
G. seekg( )
3.8 Which type of class allows to inherit only one copy
of a base class indirectly from more than one
immediate base classes
H. try
3.9 Declares a set of constants of type int I. seekp( )
3.10 We use the function to position the pointer in the
input file to read from a specified location
J. size of
K. union
L. typedef
B2.51-R3 Page 3 of 5 January, 2006
4. Each statement below has a blank space to fit one of the word(s) or phrase(s) in
the list below. Enter your choice in the “tear-off” answer sheet attached to the
question paper, following instructions therein. (1 x 10)
A. static B. run time C. friend
D. pointers E. void F. int
G. compile time H. size of I. heap
J. public K. register L. virtual
4.1 The dynamic memory is allocated by the operator new from the ________ area.
4.2 An integer variable is declared as ________ to speed up data access.
4.3 ________ pointers cannot be dereferenced without explicit type casting.
4.4 ________ function allows derived classes to provide different versions of a base class
function.
4.5 If the value of a local variable is to be preserved between successive calls to that
function, it is to be declared as ________.
4.6 Generic-data type is known at ________.
4.7 ________ function is allowed to access the private and protected members of a classusing class objects.
4.8 ________ is used to find the number of bytes taken for the user define object.
4.9 Strings are always handled through ________.
4.10 A function that has return type ________ does not return anything.

B2.51-R3 Page 4 of 5 January, 2006

                                                                      PART TWO
(Answer any FOUR questions)
5.
a) What are the differences between pointers to constants and constant pointers? Give examples.
b) What is runtime memory management? What support is provided by C++ for this and how does it differ from C’s memory management?                                                                                           (7+8)
6.
a) What is containership or delegation? How does it differ from inheritance? Explain with suitable example.
b) What are the different forms of inheritance supported by C++? Explain by writing xstatements of each type.                                                                                                                                            (10+5)
7. Write a C++ program disp to display the contents of a random file beginning with thelocation you specify on the command line.disp fixt.txt 15                                                                        (15)
8.
a) Explain the concept of operator overloading? Illustrate with suitable examples? What are the operators that cannot be overloaded?
b) What is a copy constructor? What are the advantages of a copy constructor? Give examples?
c) Write down all the rules with respect to virtual functions.                    (5+5+5)
9.
a) Write a program to demonstrate the catching of all exceptions. What happens when a raised exception is not caught by catch-block (in the absence of catching all exceptions block)?
b) What is a class template? Write a template-based complete program for adding two objects of the vector class. Use dynamic data members instead of arrays for storingvector elements.                 (8+7)
B2.51-R3 Page 5 of 5 January, 2006






B2.51-R3: INTRODUCTION TO OBJECT ORIENTED PROGRAMMING AND C++
TOTAL TIME: 3 HOURS                                                             TOTAL MARKS: 100
1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions
and PART TWO contains FIVE questions.
2. PART ONE is to be answered in the TEAR-OFF ANSWER SHEET only, attached to the  question paper, as per the instructions contained therein. PART ONE is NOT to be answered in the answer book.
3. Maximum time allotted for PART ONE is ONE HOUR. Answer book for PART TWO will
be supplied at the table when the answer sheet for PART ONE is returned. However,candidates, who complete PART ONE earlier than one hour, can collect the answer book for PART TWO immediately after handing over the answer sheet for PART ONE.
(PART ONE – 40; PART TWO – 60)
PART ONE
(Answer all the questions)
1. Each question below gives a multiple choice of answers. Choose the most appropriate
one and enter in the “tear-off” answer sheet attached to the question paper, following
instructions therein. (1 x 10)
1.1 Which of the following cannot be passed to a function?
A) Reference variables
B) Objects
C) Header files
D) Array
1.2 Which of the following contains overloaded insertion operator?
A) iostream
B) ostream
C) fstream
D) bufferstream
1.3 Which of the following operator can’t be overloaded?
A) new
B) delete
C) +
D) ?:
1.4 Which of the following is not a visibility modifier?
A) private
B) public
C) Char
D) Protected
B2.51-R3 Page 1 of 5 July, 2006
1.5 Operator overloading is called
A) Runtime polymorphism
B) Compile time polymorphism
C) Complex overloading
D) Abstract overloading
1.6 A process of a class can contain object of another class is called
A) Nesting
B) Friend
C) Data Abstraction
D) Encapsulation
1.7 Find out the function which describes special task to an operator
A) operate
B) operand
C) operator
D) opfun
1.8 Which of the following is a method which belong to a string class?
A) Equals ( )
B) Compare ( )
C) Length ( )
D) Substring ( )
1.9 Which of the following loop cause the execution of the code at least once?
A) While
B) Do…While
C) While…. Do
D) For
1.10Which of the following way are legal to access a class data member using this pointer?
A) this.x
B) *this.x
C) *(this.x)
D) (*this).x
B2.51-R3 Page 2 of 5 July, 2006
2. Each statement below is either TRUE or FALSE. Choose the most appropriate one and
ENTER in the “tear-off” sheet attached to the question paper, following instructions
therein. (1 x 10)
2.1 C++ requires const to be initialized.
2.2 When we are using manipulator we are in fact calling a member function.
2.3 We can inherit a new class from the class template.
2.4 When an exception is not caught, the program is aborted.
2.5 A class can inherit the attributes of two or more classes, is known as multilevel inheritance.
2.6 A constructor can be used to convert a class type to basic type data.
2.7 NULL is a keyword.
2.8 The static member variables must be defined outside the class.
2.9 Pure virtual functions can never have a body.
2.10 Creating a derived class from a base class requires a fundamental change to the base class.
3. Match words and phrases in column X with the closest related meaning/ word(s)/phrase(s) in
column Y. Enter your selection in the “tear-off” answer sheet attached to the question
paper, following instructions therein. (1 x 10)
X Y
Object A. Is an associative container
Friend function B. Can’t be used to overload operator
Destructor C. Is an operator
Pointer D. Is an insulation of data from direct access by the
program
Data hiding E. Is not used to create objects
Abstract class F. Can be passed as function argument.
Sub class G. Is a constant
Setw H. Is used to de-allocate memory that was allocated for an
object.
Map I. Is a process of binding of data and functions together
into a single class-type variable
Encapsulation J. Is a variable
K. Has a link to a more general class
L. Is an example of a manipulator
B2.51-R3 Page 3 of 5 July, 2006
4. Each statement below has a blank space to fit one of the word(s) or phrase(s) in the list
below. Enter your choice in the “tear-off” answer sheet attached to the question paper,
following instructions therein. (1 x 10)
A. Lifetime B. Ostream C. Calling
D. Structures E. One F. Abstract class
G. Two H. Class name I. Private
J. Default constructor K. Class L. Constant
M. Visibility N. Variable O. Void
4.1 A(n) _______ is user defined data type, which holds both the data and function.
4.2 Member functions defined inside a class specifier are _______ by default.
4.3 Storage classes concerned with the lifetime are ________ of a variable.
4.4 A function that doesn’t return anything has return type ___________.
4.5 Character ‘A’ occupies _______bytes.
4.6 Sending a message to an object is same as ________ member function.
4.7 Data and member function are public in _________ but private in classes, by default.
4.8 A constructor’s name is the same as _________.
4.9 Cerr and clog are standard streams of type_________.
4.10 An address of a variable is ________.
B2.51-R3 Page 4 of 5 July, 2006
PART TWO
(Answer any FOUR questions)
5.
a) Explain polymorphism and data hiding in c++ with suitable examples.
b) What happens if we don’t use virtual function in inheritance? Explain importance of virtual function
with this reference.
c) Explain with suitable example pointer to object. How can we access function or variable with the
help of pointer to object?
(5+5+5)
6.
a) What is an abstract class? How do you create an abstract class? Explain it using example.
b) Explain copy constructor with example. What is its use?
c) Write a program for class implementation, which takes an age, name and salary of employee.
Use a constructor for initialization of objects. Define a destructor.
(5+5+5)
7.
a) Write a class number. Calculate the power to be raised of that number.
b) Define a class publisher that stores the name of the title and another class, sales, which
stores number of sales for three months. Derive two classes: book and tape, which inherit from
both publisher and sales. Define functions in the appropriate classes to get and print the
details.
c) Distinguish clearly between scanf() & printf() in cin & cout in C++.
(4+7+4)
8.
a) Explain operator overloading with example.
b) What is inline function? How does it differ from ordinary function? Explain merits and demerits of
it.
c) Create a class month for taking a birth date between 1 to 12 month and display it.
(5+5+5)
9.
a) Explain the difference between private, protected and public access scope with respect to the
class itself, its derived class and its object.
b) Explain the technique of type conversion from one class type to another class type with
example.
c) Explain the use of except in handling in C++ program developed. Illustrate with example.
(5+5+5)
B2.51-R3 Page 5 of 5 July, 2006





B2.51-R3 Page 1 of 5 January, 2009
B2.51-R3: INTRODUCTION TO OBJECT ORIENTED PROGRAMMING AND C++
NOTE:
1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions
and PART TWO contains FIVE questions.
2. PART ONE is to be answered in the TEAR-OFF ANSWER SHEET only, attached to the
question paper, as per the instructions contained therein. PART ONE is NOT to be
answered in the answer book.
3. Maximum time allotted for PART ONE is ONE HOUR. Answer book for PART TWO will
be supplied at the table when the answer sheet for PART ONE is returned. However,
candidates, who complete PART ONE earlier than one hour, can collect the answer
book for PART TWO immediately after handing over the answer sheet for PART ONE.
TOTAL TIME: 3 HOURS TOTAL MARKS: 100
(PART ONE – 40; PART TWO – 60)
PART ONE
(Answer all the questions)
1. Each question below gives a multiple choice of answers. Choose the most
appropriate one and enter in the “tear-off” answer sheet attached to the question
paper, following instructions therein. (1 x 10)
1.1 Consider the following statements:
int x = 22, y = 15;
x = (x
What will be the value of x after executing these statements?
A) 22
B) 37
C) 7
D) Error. Cannot be executed.
1.2 Which of the following will produce a value of 9 if x=8.7?
A) floor(x)
B) abs(x)
C) log(x)
D) ceil(x)
1.3 What would be the output of the following program?
int main( )
{
int x, y=10,z=10;
x=(y==z);
cout<
return 0; }
A) 0
B) 1
C) 10
D) error
B2.51-R3 Page 2 of 5 January, 2009
1.4 When the break statement is encountered inside a loop, which one of the following
occurs?
A) control goes to the end of the program
B) control leaves the function that contains the loop
C) causes an exit from the innermost loop containing it
D) causes an exit from all the nested loop
1.5 The friend functions are used in situations where
A) we want to have access to unrelated classes
B) dynamic binding is required
C) we want to exchange data between classes
D) none of the above
1.6 A relational operator
A) assigns one operand to another
B) yields a Boolean result
C) logically combines two operands
D) None of the above
1.7 The library function exit() causes an exit from
A) the loop in which it occurs
B) the block in which it occurs
C) the function in which it occurs
D) the program in which it occurs
1.8 Which of the following is good reason to use an object-oriented language?
A) It's easier to conceptualize an object-oriented program
B) program statements are simpler than in procedural languages
C) An object-oriented program can be taught to correct its own error
D) None of the above
1.9 What is the error in the following code?
class Test
{
virtual void draw( );
};
A) No error
B) Function draw( ) should be declared as static
C) Function draw( ) should be defined
D) Test class should contain data members
1.10 A template class
A) is designed to be stored in different containers
B) works with different data types
C) generate objects which must all be identical
D) generates classes with different numbers of member functions
B2.51-R3 Page 3 of 5 January, 2009
2. Each statement below is either TRUE or FALSE. Choose the most appropriate one
and ENTER in the “tear-off” sheet attached to the question paper, following
instructions therein. (1 x 10)
2.1 The pre-increment and post-increment ++ operator can be overloaded.
2.2 It is illegal to make objects of one class as members of another class.
2.3 Only when an argument has been initialized to zero value, it is called the default
argument.
2.4 When calling a function, if the arguments are passed by reference, the function works
with the actual variables in the calling program.
2.5 The precedence of an operator can be changed by overloading it.
2.6 A pointer to a base class can point to an object of a derived class of that base class.
2.7 A derived class is often called a subclass because it represents a subset of its base
class.
2.8 Can we make a class as a friend?
2.9 The expression for (;;) is the same as a while loop with a test expression of true.
2.10 A const member function prevents modification of any of its class’s member data.
3. Match words and phrases in column X with the closest related meaning/
word(s)/phrase(s) in column Y. Enter your selection in the “tear-off” answer sheet
attached to the question paper, following instructions therein. (1 x 10)
X Y
3.1 The ability to change the definition of an
inherited method or attribute in a subclass.
A. <<
3.2 Rules that governs the construction of
statement.
B. late binding
3.3 A data type that holds the address of a location
in memory.
C. syntax
3.4 A short piece of text, or text template that can
be expanded into a longer text.
D. overriding
3.5 The operator stops reading a string when a
space is encounter.
E. pointer
3.6 To convert a variable from one type to another
type by explicitly.
F. >>
3.7 The visible methods of an object. G. stream
3.8 A source from which input data can be obtained
or a destination to which output data can be
sent.
H. parameter
3.9 A function that although not a member of a
class is able to access the private members of
that class.
I. friend
3.10 The addresses of the functions are determined
at run time.
J. Macro
K. cast
L. interface
B2.51-R3 Page 4 of 5 January, 2009
4. Each statement below has a blank space to fit one of the word(s) or phrase(s) in
the list below. Enter your choice in the “tear-off” answer sheet attached to the
question paper, following instructions therein. (1 x 10)
A. descructor B. ios C. polymorphism
D. ctype.h E. return F. class library
G. abstraction H. multiple inheritance I. constructor
J. overloading K. multilevel inheritance L. conio.h
4.1 A(n) ________ statement supplies a value from the called function to the calling
function.
4.2 ________ allows a derived class to have more than one base class.
4.3 toupper( ) is defined in ________.
4.4 ________ is the process of highlighting the essential, inherent aspects of an entity while
ignoring irrelevant details.
4.5 A group of related classes, supplied as a separate product, is often called a(n)
________.
4.6 A(n) ________ is called to deallocate memory of the objects of a class.
4.7 The ability of a function or operator to act in different ways on different data types is
called ________.
4.8 The base class for most stream classes is the ________ class.
4.9 getch( ) is defined in ________.
4.10 A language feature that allows a function or operator to be given more than one
definition is called ________.
B2.51-R3 Page 5 of 5 January, 2009
PART TWO
(Answer any FOUR questions)
5.
a) What is the difference between an object-based language and an object-oriented
language?
b) What do you mean by abstraction? Is it necessary to create good abstraction?
c) Why did people change over from structured programming to object-oriented
programming?
d) Explain the advantages of pointers over references.
e) Why do we need to use constructors?
(3x5)
6.
a) Why member functions are not virtual by default?
b) Write a program in C++ that contains a class derived from base. The base class should
have a virtual function fun( ) and it should be overridden. Try to call fun( ) from the
constructor of the base class and display the result.
c) Implement a class sample with an overloaded + operator. Explain the following
statements:
s2=s1+10;
s2=10+s1;
where s1 and s2 are objects of class sample.
(3+6+6)
7.
a) Explain the concept of operator overloading. Illustrate operator overloading concept to
concatenate strings.
b) How is polymorphism achieved at run time? Explain with C++ coding.
(8+7)
8.
a) Distinguish between overloaded functions and function templates.
b) Imagine a publishing company that markets both book and audiocassette version to its
works. Create a class publication that stores the title (a string) and price (type float) of a
publication. From this class derive two classes: book, which adds a page count (type
int); and tape, which adds a playing time in minutes (type float). Each of these three
classes should have a getdata( ) function to gets its data from the user at the keyboard,
and a putdata( ) function to display its data.
Write a main( ) program in C++ to test the book and tape classes by creating instances
of them, asking the user to fill in data with getdata( ), and than displaying the data with
putdata( ).
(5+10)
9. Write short notes on any three:
a) Stream classes
b) Friend function
c) Exception handling
d) Multiple inheritance
(3x5)








B2.51-R3: INTRODUCTION TO OBJECT ORIENTED PROGRAMMING AND C++
NOTE:
1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions
and PART TWO contains FIVE questions.
2. PART ONE is to be answered in the TEAR-OFF ANSWER SHEET only, attached to
the question paper, as per the instructions contained therein. PART ONE is NOT to
be answered in the answer book.
3. Maximum time allotted for PART ONE is ONE HOUR. Answer book for PART TWO
will be supplied at the table when the answer sheet for PART ONE is returned.
However, candidates, who complete PART ONE earlier than one hour, can collect the
answer book for PART TWO immediately after handing over the answer sheet for
PART ONE.
TOTAL TIME: 3 HOURS TOTAL MARKS: 100
(PART ONE – 40; PART TWO – 60)
PART ONE
(Answer all the questions)
1. Each question below gives a multiple choice of answers. Choose the most
appropriate one and enter in the “tear-off” answer sheet attached to the question
paper, following instructions therein. (1 x 10)
1.1 Which of the following cannot be passed to a function?
A) Pointers.
B) Arrays.
C) Function name.
D) Header files.
1.2 Static variable in a function is considered as
A) Global variable to the whole program.
B) Global to main () function.
C) Global to the function in which it is declared.
D) None of the above.
1.3 Which of the following are not keywords?
A) double
B) int
C) NULL
D) None of the above
1.4 When the break statement is encountered inside a loop, which one of the following
occurs?
A) Control goes to the end of the program.
B) Control leaves the function that contains the loop.
C) Causes an exit from the innermost loop containing it.
D) Causes an exit from all the nested loop.
1.5 Which of the following are valid methods for accessing the first element of the array
item?
A) item.1
B) item[1]
C) item[0]
B2.51-R3 Page 1 of 5 July, 2008
D) item(0)
B2.51-R3 Page 2 of 5 July, 2008
1.6 Inline function acts as a
A) Function.
B) Macro.
C) Operator.
D) Manipulator.
1.7 A global variable declaration is made
A) Only in main function.
B) Only in functions other than main function.
C) Only outside functions.
D) None of the above.
1.8Binary overloaded operators are passed.
A) two arguments
B) one arguments
C) no arguments
D) three arguments
1.9 ios represents
A) A class member function.
B) A constant object.
C) A stream.
D) A base class.
1.10 #include is a
A) Compiler statement
B) Debugging statement
C) Pre-processor statement
D) None of the above
B2.51-R3 Page 3 of 5 July, 2008
2. Each statement below is either TRUE or FALSE. Choose the most appropriate one
and ENTER in the “tear-off” sheet attached to the question paper, following
instructions therein. (1 x 10)
2.1 Pointer to a function cannot be created.
2.2 Virtual classes are the same as virtual function.
2.3 A class object can have a pointer, but its data members cannot have pointers.
2.4 For destroying class objects, we use garbage collector technique.
2.5 Virtual functions cannot be static members.
2.6 iostream is inherited from istream, ostream and ios class.
2.7 Functions can return an object.
2.8 Macros work in the same way as functions work.
2.9 Function parameter cannot be a given default value.
2.10 Template is a keyword.
3. Match words and phrases in column X with the closest related meaning/
word(s)/phrase(s) in column Y. Enter your selection in the “tear-off” answer sheet
attached to the question paper, following instructions therein. (1 x 10)
X Y
3.1 A class that contains objects of other classes. A. Multiple inheritance
3.2 Functions in C++ can be given default values. B. Hierarchical inheritance
3.3 Making an outside member function as an inside
member function.
C. Memory taken by data
members and members
functions
3.4 Upon creation of objects they occupy memory
space.
D. Using object pointers
3.5 A variable is normally used to maintain values
common to the entire class.
E. Destructor
3.6 Derivation of several classes from a single base
class.
F. Private or Public
3.7 A function is invoked when the scope of the
object is over.
G. Container class
3.8 The visibility mode in the derivation of a new
class can be
H. Private or Protected or Public
3.9 Virtual functions are accessed in a program. I. Prototypes
3.10 Derivation of a single class from many base
classes.
J. Static data member
K. Inline
L. Memory taken by data
members only
M. Constructor
B2.51-R3 Page 4 of 5 July, 2008
4. Each statement below has a blank space to fit one of the word(s) or phrase(s) in
the list below. Enter your choice in the “tear-off” answer sheet attached to the
question paper, following instructions therein. (1 x 10)
A. public B. namespace name C. constructor
D. istream& E. Standard Template
Library
F. free store
G. stream& H. Local I. friend
J. class K. global L. Open
M compile-time N flush O run-time
4.1 Classes can be defined and used inside a function or a block. Such classes are called
as ________ classes.
4.2 Same variable declared and assigned with different values in various nested blocks can be
accessed by using ________.
4.3 The class cannot have virtual ________, but can contain virtual destructor.
4.4 The new and delete are known as ________ operators.
4.5 The typeid operator is used to find the type at ________ of unknown objects.
4.6 The collection of generic classes and functions is called ________.
4.7 The flag ios::stdio is used to ________ stdout and stderr after insertion.
4.8 ________ functions have access to the private and protected members of a class.
4.9 To get benefits of virtual functions supporting runtime polymorphism, they should be
declared in the ________ section of a class.
4.10 The overloading of extraction operator for user defined types should have a return type
of ________.
B2.51-R3 Page 5 of 5 July, 2008
PART TWO
(Answer any FOUR questions)
5. Write a program in C++, to create a STUDENT class having name of student maximum
of 20 characters, and the (whole number) individual marks in four tests and the average
(whole number) of these four tests as elements of the class. Also the member function
AVG ( ), READDATA ( ) and DISPLAY ( ) of the class. Read the value of N as number of
students, and their names and respective marks in four tests and store these N student
objects in the program dynamically. Now process this information in member function
AVG ( ) to find the average of marks of these N individual students and store them in the
average data member of these N objects. If the remainder of the average is greater than
or equal to 50% of the divisor, increment the average by one. Print the name and
average of the tests for all students.
(15)
6. Design classes such that they support the following statements:
Dollar d1, d2;
Rupee r1, r2;
Write a complete program which does such conversions according to the world market
value. Take $ 1 = Rupee 39.45 as a conversion factor.
(15)
7.
a) What are manipulators? Write the general form of the user defined manipulators.
b) Design a single manipulator format to provide the following output specifications for
printing float values:
i) 10 columns width.
ii) Right-justified.
iii) Two digits precision.
iv) Filling of unused places with *.
v) Trailing zeroes shown.
c) Can we place two or more catch blocks together to catch and handle multiple types of
exceptions thrown by a try block? If your answer is yes, please write the syntax.
(5+5+5)
8. Write a program disp to display the contents of a random file beginning with the location
you specify on the command line.
disp file.txt 15
(15)
9.
a) Write a program to demonstrate the catching of all exceptions. What happens when a
raised exception is not caught by catch-block (in the absence of catching all exceptions
block)?
b) What is a class template? Write a template-based complete program for adding two
objects of the vector class. Use dynamic data members instead of arrays for storing
vector elements.
(8+7)
B2.51-R3 Page 6 of 5 July, 2008





B2.51-R3: INTRODUCTION TO OBJECT ORIENTED PROGRAMMING AND C++
NOTE:
1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions
and PART TWO contains FIVE questions.
2. PART ONE is to be answered in the TEAR-OFF ANSWER SHEET only, attached to
the question paper, as per the instructions contained therein. PART ONE is NOT to be
answered in the answer book.
3. Maximum time allotted for PART ONE is ONE HOUR. Answer book for PART TWO
will be supplied at the table when the answer sheet for PART ONE is returned.
However, candidates, who complete PART ONE earlier than one hour, can collect the
answer book for PART TWO immediately after handing over the answer sheet for
PART ONE.
TOTAL TIME: 3 HOURS TOTAL MARKS: 100
(PART ONE – 40; PART TWO – 60)
PART ONE
(Answer all the questions)
1. Each question below gives a multiple choice of answers. Choose the most
appropriate one and enter in the “tear-off” answer sheet attached to the question
paper, following instructions therein. (1 x 10)
1.1 How would you interpret a statement like *a + = 40;
A) Contents of a location a incremented by 40 and stored in a
B) Address of a location a incremented by 40 and stored in a
C) Address and contents of a location a incremented by 40 and stored in a
D) Contents of a location a is stored in a and incremented by 40
1.2 The function’s most important role is to
A) Give a name to a block
B) Reduce program size
C) Accept arguments and provide a return value
D) Organize a program into conceptual units.
1.3 The keyword friend can appear in
A) The class allowing access to another classes
B) The class desiring access to another classes
C) It does not matter where you put the keyword
D) The scope of the class
1.4 What is achieved by the following declaration in class structure:
void operator + + ( ) {C+ + ;}
A) + + overloaded
B) pre increment
C) post increment
D) All of the above
1.5 A function in a class declared as private is accessible to-
A) Member function of its derived class of that class
B) Member function of all classes
C) Member function of that class
B2.51-R3 Page 1 of 5 January, 2008
D) None of the above
B2.51-R3 Page 2 of 5 January, 2008
1.6 Which of the following are not keywords?
A) Null
B) protected
C) abstract
D) string
1.7 Which of the following would be an invalid class declaration?
A) Class d: public b2, public b1
B) Class d: class b2, class b1
C) Class d: public b2, b1
D) Class d: b2, b1
1.8 Consider the following code definition:
Class Person
{
};
Class Student: protected Person
{
};
What will happen when one tries to compile this class?
A) Will not compile, because class body of Person is not defined
B) Will not compile, because of Student is not defined
C) Will compile successfully
D) Will not compile, because class Person is not public inherited.
1.9 A static function
A) should be called when an object is destroyed
B) can be called using class name and function name
C) can be called using object and function name
D) is used when a dummy object is created
1.10Redirection redirects
A) A stream from a file to the screen
B) A file from a device to a stream
C) The screen from a device to a stream
D) A device from the screen to a file
B2.51-R3 Page 3 of 5 January, 2008
2. Each statement below is either TRUE or FALSE. Choose the most appropriate one
and ENTER in the “tear-off” sheet attached to the question paper, following
instructions therein. (1 x 10)
2.1 In C++, declaration can appear almost anywhere in the body of the function.
2.2 A C++ function can return multiple values to the calling function.
2.3 Defining a class also creates objects.
2.4 Members of a class specified as private are accessible only to the functions of the class.
2.5 Destructors should be defined by class name or constructor name.
2.6 If a unary operator ++ is overloaded, it makes no difference if it is used as pre or post
increment with an object.
2.7 A member function in a base class can be accessed by an object of its derived class.
2.8 Pointers to an int and float are same.
2.9 All functions in an abstract base class must be declared pure virtual.
2.10 Exception means out of the ordinary or deviating from the normal course.
3. Match words and phrases in column X with the closest related meaning/
word(s)/phrase(s) in column Y. Enter your selection in the “tear-off” answer sheet
attached to the question paper, following instructions therein. (1 x 10)
X Y
3.1 Private A. Is the prototype of a function
3.2 Inheritance B. Is used to design a single class/function that operates on
the data of many types
3.3 Declaration C. Is used in the base class
3.4 Calling member
function
D. Is defined and declared in the base class
3.5 Polymorphism E. Is the base class for most of the stream classes
3.6 Virtual function F. Ability of an operator to act in different ways on different
data types
3.7 Template G. Means data hiding
3.8 Destructor H. Functions are automatically called when derived class
object gets destroyed
3.9 ios I. Is same as sending a message to an object
3.10 stew J. Class members can be accessed only by member and
friend functions of that class
K. Is an example of manipulator
L. Is used in the derived class
B2.51-R3 Page 4 of 5 January, 2008
4. Each statement below has a blank space to fit one of the word(s) or phrase(s) in
the list below. Enter your choice in the “tear-off” answer sheet attached to the
question paper, following instructions therein. (1 x 10)
A. Data hiding B. >> C. Declaration
D. Polymorphism E. Definition F. Arguments
G. Catch H. Address I. Pointer
J. Private K. << L. Public
M. Ordinary N. Operator O. Constructor
4.1 A function prototype tells the compiler the return type, name and ________.
4.2 ________ is the symbol for insertion or put to operator.
4.3 Memory gets allocated during________ of a function.
4.4 Principal objective of OOP is ________.
4.5 C++ features which enables you to initialize an object on creation is called ________.
4.6 The keyword ________ is used for an overloaded operator function definition.
4.7 ________ type of declaration of a base class enables an object of a derived class to
access member functions.
4.8 The symbol & is called________.
4.9 Derived function uses a virtual function by________.
4.10 C++ language uses ________ keyword to handle exception.
B2.51-R3 Page 5 of 5 January, 2008
PART TWO
(Answer any FOUR questions)
5.
a) Discuss the salient features of C++ in comparison to C. Explain why object oriented
program is more robust than structured program.
b) Discuss the function overloading and its importance in C++.
c) Write a C++ program to declare a class called ‘person’ having data members- ‘name’,
‘age’ and ‘salary’ of the appropriate types. Write a constructor to define the value of data
variables. Also write a method called display ( ) that will display the current values of
data variables. Create two objects of this class & set their data values as follows:
1. Name: Rakesh, Age: 25, Salary: 20000.00
2. Name: Mitul, Age: 28, Salary: 25000.00
(5+3+7)
6.
a) What is inheritance? What are the types of inheritance? How can you initialize base
class member through a derived class object?
b) Classify data types in C++.
c) Write a programme that reads elements of an array of ten elements and displays the
largest and smallest in that array.
d) List some of the special properties of the constructor functions. In which direction
constructors and destructors are invoked when base class is one and derived class are
two?
(6+2+3+4)
7.
a) Declare a class matrix and write a function to read all the elements of a matrix of
size m x n from the keyboard for creating objects.
b) Abstract class provides a base upon which other classes may be built. Justify.
c) What is dynamic memory allocation?
d) What are input and output streams? Describe various classes available for file
operations.
(5+2+2+6)
8.
a) Write a function using reference variables as arguments to swap the values of a pair of
integers.
b) Discuss the exception handling in C++.
c) Define the following terms with proper illustration:
Object, Polymorphism, Data hiding.
(5+5+5)
9.
a) What is a pure virtual function? Show its use in example.
b) What is operator overloading? What is the use of operator overloading? If meaning of
any operator is changed, will compiler generate error?
c) Differentiate between copy constructor and default constructor.
(5+5+5)
B2.51-R3 Page 6 of 5 January, 2008




B2.51-R3: INTRODUCTION TO OBJECT ORIENTED PROGRAMMING AND C++
NOTE:
1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions
and PART TWO contains FIVE questions.
2. PART ONE is to be answered in the TEAR-OFF ANSWER SHEET only, attached to
the question paper, as per the instructions contained therein. PART ONE is NOT to
be answered in the answer book.
3. Maximum time allotted for PART ONE is ONE HOUR. Answer book for PART TWO
will be supplied at the table when the answer sheet for PART ONE is returned.
However, candidates, who complete PART ONE earlier than one hour, can collect the
answer book for PART TWO immediately after handing over the answer sheet for
PART ONE.
TOTAL TIME: 3 HOURS TOTAL MARKS: 100
(PART ONE – 40; PART TWO – 60)
PART ONE
(Answer all the questions)
1. Each question below gives a multiple choice of answers. Choose the most
appropriate one and enter in the “tear-off” answer sheet attached to the question
paper, following instructions therein. (1 x 10)
1.1 The statement char s = ‘A’ will internally assign value to s is
A) 0
B) 90
C) 65
D) 127
1.2 Condition checking in C++ can be done by using the statement
A) If-else
B) option
C) choice
D) select
1.3 A relational operator
A) assigns one operand to another.
B) yields a Boolean result.
C) logically combines two operands.
D) none of the above
1.4 The library function exit() causes an exit from
A) the loop in which it occurs.
B) the block in which it occurs.
C) the function in which it occurs.
D) the program in which it occurs.
1.5 If p is a pointer, then p++ means
A) Increment the value of p
B) Increment the pointer p
C) Increment the address of the variable to which p is pointing
B2.51-R3 Page 1 of 5 July, 2007
D) Increment the value of the variable to which p is pointing
B2.51-R3 Page 2 of 5 July, 2007
1.6 Which of the following is good reason to use an object-oriented language?
A) It's easier to conceptualize an object-oriented program.
B) program statements are simpler than in procedural languages.
C) An object-oriented program can be taught to correct its own error.
D) None of these
1.7 Consider the following class definition
class Person
{}
;
class Student: protected Person
{}
;W
hat happens when we try to compile this class?
A) Will not compile because class body of Person is not defined.
B) Will not compile because class body of Student is not defined.
C) Will not compile because class of Person is not public inherited.
D) Will compile successfully.
1.8 What is the error in the following code?
class Test
{
virtual void draw( ) ;
};
A) No error
B) Function draw( ) should be declared as static.
C) Function draw( ) should be defined.
D) Test class should contain data members.
1.9 If a subclass contains a method with the same name and arguments as in the base class,
it is
A) overloading
B) overriding
C) polymorphism
D) error
1.10 If we generalize functions, we get a
A) model
B) template
C) structure
D) class
B2.51-R3 Page 3 of 5 July, 2007
2. Each statement below is either TRUE or FALSE. Choose the most appropriate one
and ENTER in the “tear-off” sheet attached to the question paper, following
instructions therein. (1 x 10)
2.1 In general, switch is faster than if-else.
2.2 By default the members of a class are private.
2.3 The length of a string object s1 can be obtained using the expression s1.length.
2.4 All functions in an abstract base class must be declared pure virtual.
2.5 Throwing an exception always causes program termination.
2.6 The expression for (;;) is the same as a while loop with a test expression of true.
2.7 We cannot use the % operator to compute the remainder of an array index.
2.8 There is no direct mechanism to locate a sub-string in a string.
2.9 Static member functions are independent of objects.
2.10 If no overloaded operators are provided, C++ automatically provides them.
3. Match words and phrases in column X with the closest related meaning/
word(s)/phrase(s) in column Y. Enter your selection in the “tear-off” answer sheet
attached to the question paper, following instructions therein. (1 x 10)
X Y
3.1 The act of representing the essential features of
something without including much detail.
A. copy constructor
3.2 To convert a variable from one type to another
type by explicitly.
B. late binding
3.3 The constructor that creates a new class object
from an existing object of the same class.
C. printf( )
3.4 The addresses of the functions are determined at
run time
D. interface
3.5 The visible method of an object. E. abstraction
3.6 A value, variable or expression that selects a
particular element of an array.
F. cast
3.7 Writing formatted output to stdout. G. overloading
3.8 The address of an actual parameter is implicitly
passed to a function.
H. flowchart
3.9 Rules that governs the construction of statement. I. reusability
3.10 A feature which allows to build new classes from
existing classes.
J. pass by reference
K. index
L. syntax
M. pass by value
B2.51-R3 Page 4 of 5 July, 2007
4. Each statement below has a blank space to fit one of the word(s) or phrase(s) in
the list below. Enter your choice in the “tear-off” answer sheet attached to the
question paper, following instructions therein. (1 x 10)
A. encapsulation B. ios C. one value
D. class E. break F. class library
G. delete H. multiple inheritance I. two values
J. Scope-resolution operator K. data hiding L. virtual functions
4.1 If we do not write the ________ statement, even if a condition matches, switch continues
execution.
4.2 A function is allowed to return ________.
4.3 The ________ usually resolves ambiguities.
4.4 A template argument is preceded by the keyword ________.
4.5 A group of related classes, supplied as a separate product, is often called a(n) ________.
4.6 The ________ operator is used to release memory allocated dynamically.
4.7 ________ allows a derived class to have more than one base class.
4.8 C++ achieves polymorphism through ________.
4.9 The base class for most stream classes is the ________ class.
4.10 The wrapping up of data and functions into a single unit is called ________.
B2.51-R3 Page 5 of 5 July, 2007
PART TWO
(Answer any FOUR questions)
5.
a) What is object oriented programming? How is it different from procedure-oriented
programming?
b) What is the difference between the while and do-loops with respect to the respect to the
number of times the loop executed?
c) What is the main advantage of passing arguments by reference? Explain this with an
example.
(5+5+5)
6.
a) What is operator overloading? Illustrate operator overloading concept to concatenate
strings.
b) What is a pointer? Explain the difference between the address stored in a pointer and
the value at that address.
c) Why do we need virtual functions?
(5+5+5)
7.
a) Explain why do we need to use constructors? Explain a copy constructor with an
example.
b) What is an exception? How is an exception handled in C++?
c) Write a program that illustrates the application of multiple catch statements.
(5+5+5)
8.
a) What are friend functions and friend classes? Write a normal function which adds
objects of the complex number class. Declare this normal function as friend of the
complex class.
b) Distinguish between overloaded functions and function templates.
c) How is polymorphism achieved at run time? Explain with coding.
(7+4+4)
9.
a) What does the following statement do?
i) *ptr+=1;
ii) ++*ptr;
iii) (*ptr)++;
iv) *ptr++;
b) What do you understand by the term Abstract Data Type?
c) Write a program to show that the declaration of a class ‘Rectangle’, which derives from
the class ‘square’, which in turn derives from the class ‘shape’.
d) Explain ‘Ambiguity Resolution in Multiple Inheritances’.
(4+3+4+4)
B2.51-R3 Page 6 of 5 July, 2007







B2.51-R3: INTRODUCTION TO OBJECT ORIENTED PROGRAMMING AND C++
NOTE:
1. There are TWO PARTS in this Module/Paper. PART ONE contains FOUR questions
and PART TWO contains FIVE questions.
2. PART ONE is to be answered in the TEAR-OFF ANSWER SHEET only, attached to
the question paper, as per the instructions contained therein. PART ONE is NOT to
be answered in the answer book.
3. Maximum time allotted for PART ONE is ONE HOUR. Answer book for PART TWO
will be supplied at the table when the answer sheet for PART ONE is returned.
However, candidates, who complete PART ONE earlier than one hour, can collect the
answer book for PART TWO immediately after handing over the answer sheet for
PART ONE.
TOTAL TIME: 3 HOURS TOTAL MARKS: 100
(PART ONE – 40; PART TWO – 60)
PART ONE
(Answer all the questions)
1. Each question below gives a multiple choice of answers. Choose the most
appropriate one and enter in the “tear-off” answer sheet attached to the question
paper, following instructions therein. (1 x 10)
1.1 The range of values for the long data type on a 16-bit machine is
A) -231 to 231-1
B) -264 to 264
C) -263 to 263-1
D) -216 to 216-1
1.2 For representing polynomial in memory, using linked list, each node must have following
number of fields
A) 2
B) 3
C) 1
D) None of the above
1.3 Inheritance is a way to
A) Create general classes from more specific classes
B) Create specific classes from more general classes
C) Improve data hiding and encapsulation
D) None of the above
1.4 Consider the following code:
if(number>0)
cout<<”Number is Positive”;
else
cout<<”Number is Negative”;
What will be the output if number is equal to zero?
A) Number is Positive
B) Number is Negative
C) Both A) & B)
B2.51-R3 Page 1 of 5 January, 2007
D) None of the above
B2.51-R3 Page 2 of 5 January, 2007
1.5 Which of the following can’t be passed to a function
A) Reference variable
B) Array
C) Class objects
D) Header files
1.6 Which of the following is legal declaration of a reference?
A) int &a=10;
B) int &a=m;
C) int *a=&15;
D) int &a=m++;
1.7 If p and q are two pointers of type int and m is an int type variable, which of the following is
legal?
A) p-q
B) p*q
C) p/q
D) m%n
1.8 Consider the following code definition:
class Person
{}
;
class Student: protected Person
{}
;
What happens when we try to compile this class?
A) Will not compile class body of Person is not defined
B) Will not compile because of Student is not defined
C) Will compile successfully
D) Will not compile because class Person is not public inherited.
1.9 We can make a class abstract by
A) Declaring it abstract using the static keyword
B) Declaring it abstract using the virtual keyword
C) Making all member functions constant
D) Making at least one member function as pure virtual function
1.10An exception is caused by
A) A hardware problem
B) A problem in the operating system
C) A run-time error
D) A syntax error
B2.51-R3 Page 3 of 5 January, 2007
2. Each statement below is either TRUE or FALSE. Choose the most appropriate one
and ENTER in the “tear-off” sheet attached to the question paper, following
instructions therein. (1 x 10)
2.1 A ‘Do’ loop is executed at least once.
2.2 Objects of the string class can be copied with the assignment operator.
2.3 Inheritance is used to improve data hiding and encapsulation.
2.4 An abstract class is never used as a base class.
2.5 A file pointer always contains the address of the file.
2.6 Template creates different versions of a function at run time.
2.7 Throwing an exception always causes program termination.
2.8 Derived classes of an abstract class that do not provide an implementation of a pure
virtual function are also abstract.
2.9 A function template can have more than one template argument.
2.10 The function that has return type void does not return anything.
3. Match words and phrases in column X with the closest related meaning/
word(s)/phrase(s) in column Y. Enter your selection in the “tear-off” answer sheet
attached to the question paper, following instructions therein. (1 x 10)
X Y
3.1 Reusability A. Can appear in the class desiring access to another class
3.2 Abstract data
type
B. is a well-defined and complete data abstraction that uses the
principle of information hiding.
3.3 Function C. Is used to delete the memory allocated by new.
3.4 Token D. Makes a program run faster
3.5 Encapsulation E. It means one name having multiple forms.
3.6 Friend F. A class can contain objects of other classes
3.7 Static_ cast G. It may be over loaded.
3.8 Delete H. This operator is used for any standard conversion of data type.
3.9 Local variable I. It is the smallest individual units in a program
3.10 Polymorphism J. The wrapping up of data and functions into a single unit
K. Is a variable defined within a statement block
L. Is provided by the concept of Inheritance
B2.51-R3 Page 4 of 5 January, 2007
4. Each statement below has a blank space to fit one of the word(s) or phrase(s) in
the list below. Enter your choice in the “tear-off” answer sheet attached to the
question paper, following instructions therein. (1 x 10)
A. class name B. object C. new
D. brackets E. comment F. zero
G. iostream H. inheritance I. multilevel
J. static K. public L. virtual
M. protected N. istream O. catch
4.1 ___________ is used to document a program.
4.2 A constructor’s name is same as _______________.
4.3 A(n) ________ function causes its class to be abstract.
4.4 A pointer to _________ can hold pointers to any data type.
4.5 _________ are used to change the order of precedence in evaluation of expression.
4.6 The process by which objects of one class acquire the attributes of objects of another
class is known as __________.
4.7 The class _____________ declares input function such as get( ) and read( ).
4.8 The___________ operator dynamically allocates memory for the object of a specific
type.
4.9 A virtual function can be made pure virtual function by placing__________ at the end of
its prototype in the class definition.
4.10 Exceptions are thrown from a try statement to a(n) __________ block.
B2.51-R3 Page 5 of 5 January, 2007
PART TWO
(Answer any FOUR questions)
5.
a) Differentiate between declaration and definition in C++.
b) Explain the concept of exception handling.
c) Write a class employee with two function get data and put data to read the name and
number of employee and display them respectively. Drive two classes one manager and
other scientist. In manager class add one more variable title. In scientist class add more
variable publication and display them.
(2+3+10)
6.
a) How can a '::' operator be used as unary operator?
b) What are the merits and demerits of friend function?
c) Why does the function arguments are called as "signatures"? Give example.
d) How do structures in ‘C’ and ‘C++’ differ? How does a ‘C++’ structure differ from a class?
(3+4+4+4)
7.
a) Differentiate between early binding and late binding.
b) Write ‘C++’ class for the following:
To represent two-dimensional point (x, y), class should contain all different constructors
and methods to print point (x, y) format and also to add two points by adding their x and
y values.
c) Write a ‘C++’ program for scalar multiplication where each item in array of N values is
multiplied by a given constant. Write necessary class and test it using main( ).
(5+5+5)
8.
a) Write a program to concatenate two strings using operator overloading.
b) Write a function using reference variable as arguments to swap the values of a pair of
integers.
c) Write short note on: static variables and static functions.
(5+5+5)
9.
a) What is a class template? List the merits and demerits of using a template in ‘C++’.
b) When is it necessary to use member-wise initialization list (also known as header
initialization list) in ‘C++’?
c) Explain stream classes, stream class hierarchy and stream manipulators.
d) Justify the use of constructors and destructors in C++.
(4+4+3+4)
B2.51-R3 Page 6 of 5 January, 2007



















No comments:

Post a Comment