0% found this document useful (0 votes)
18 views4 pages

2015 CE104 University Paper

Uploaded by

AneriMehta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views4 pages

2015 CE104 University Paper

Uploaded by

AneriMehta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Candidate Seat no………….

CHAROTAR UNIVERSITY OF SCIENCE & TECHNOLOGY


Second Semester of B. Tech (CE/IT/EC) Examination
May 2015
CE104 Object Oriented Programming with C++
Date: 13.05.2015, Wednesday Time: 01.30 p.m. To 04.30 p.m. Maximum Marks: 70
Instructions:
1. The question paper comprises two sections.
2. Section I and II must be attempted in separate answer sheets.
3. Make suitable assumptions and draw neat figures wherever required.

SECTION – I
Q-1 Find the most appropriate option for the following questions. [07]
(i) Function declaration with default arguments are given below. Which among the
following is legal function declaration?
(A) int add ( int m = 5,int k, int n ); (B) int add ( int m = 0, int k, int n = 10);
(C) int add ( int m, int k= 8, int n = 10); (D) int add ( int m , int k = 0 , int n );

(ii) Copy constructor has following properties :


(1) A copy constructor has a return type
(2) An argument passed to copy constructor is passed by value.
Which one of the following is the correct option:
(A) (1) is correct and (2) is wrong (B) (1) is wrong and (2) is correct
(C) Both (1) and (2) are correct (D) Neither (1) nor (2) is correct

(iii) In function overloading, the correct function to be invoked is determined by


checking which of the following:
(A) Return type (B) number of arguments
(C) Type of argument (D) Both (B) and (C)
(iv) State whether the given statements are true or false.
i) We cannot make the function inline by defining a function outside the class.
ii) A member function can be called by using its name inside another member
function of the same class, this is known as nesting of the member function.
(A) i) True, ii) True (B) i) True, ii) False
(C) i) False, ii) True (D) i) False, ii) False
(v) Which concept of Object Oriented programming refers to the act of representing
essential features without including the background details or explanation?

(A) Encapsulation (B) Abstraction (C) Dynamic binding (D) Inheritance


Page 1 of 4
Candidate Seat no………….

(vi) Which of the following is a correct option about friend function in C++.
i) It is in the scope of the class to which it has been declared as friend.
ii) It can be invoked like a normal function without the help of any object.
(A) i)-True, ii)-True (B) i)-False, ii)-True
(C) i)-True, ii)-False (D) i)-False, ii)-False
(vii) Which Variable provides an alias (alternative name) for a previously defined
variable?
(A) Object (B) Static variable (C) Reference Variable (D) Default Variable
Q – 2 (A) Write down the correct output for the following code. [04]
1. 2.
int fun(int a, int b = 1, int c =2) int main()
{ {
return (a + b + c); int a,b;
} a = (b = 50) +10;
cout<<"a = "<<a<<endl;
int main() cout<<"b = "<<b<<endl;
{ float x=23.4;
int x,y=10,z=10; cout.fill('*');
x=(y==z); cout.width(10);
cout<<x<<endl; cout<<x<<endl;
cout<<fun(x,y)<<endl; float y=54.4;
return 0; cout.setf(ios::showpos);
} cout<<y<<endl;
return 0;
}
Q – 2 (B) Answer any two questions. [12]
(i) Explain Call by reference and Return by reference with example.
(ii) Draw the memory allocation of a class having 3 data-members and 2 member
functions of 3 objects of the same class and also explain it.
(iii) Explain what a constructor is with example. What are the properties of a Constructor?
Q-3 Answer any two of the following program. [12]
1. Create a class POUND having data members: float pounds. A member function
should enter their values and another member function print their values in pounds.
Function should add two objects of type POUND passed as arguments such that it
supports p3.add (p1, p2). Here p1, p2 and p3 are objects of class POUND. Write a
main ( ) program to test all the functions.
2. Create a class Corporate which contains name of employee and salary in float and
member function to display the data. Create a default constructor, parameterized
constructor and copy constructor for the class Corporate. Write main function
which calls every constructor.

Page 2 of 4
Candidate Seat no………….

3. Define the class Person having Name and Age as data member. Define two classes
Student and Professor which are both inherited publicly from class person. Student
class displays the name and CGPA (grade points in float) and Professor Class
displays the Name and number of publications (int). Write a main program to
display the data of 3 student and 4 professor.
SECTION – II
Q-4 Find the most appropriate option for the following questions. [07]

(i) When class X is inherited from class Y, what is the order in which the constructers
of those classes are called
(A) Class X first, Class Y next (B) Class Y first, Class X next
(C) Class X's only as it is the child class (D) Class Y's only as it is the base class
(ii) Which of the following operator can be overloaded by operator member function
but cannot be overloaded using friend function?
(A) Scope resolution operator (B) Assignment Operator
(B) sizeof () operator (D) Conditional operator
(iii) Which class cannot be used to create objects of its own and has at least one pure
virtual function?
(A) Virtual class (B) Abstract class (C) Friend class (D) Local class
(iv) If we derive a Class with protected visibility, the public data members in base class
will be available with following visibility.
(A) protected (B) public (C) private (D) Both (A) and (C)
(v) A pure virtual function in C++ can be declared as
(A) pure virtual void display() = 0; (B) virtual void display() = null;
(C) virtual void display() = 0; (D) pure virtual void display() = null;
(vi) The following ios function will set the number of decimal places
(A) setprecision( ) (B) precision( )
(C) setw( ) (D) width( )
(vii) In file, which of the following error handling function returns true when an input or
output operation has failed
(A) eof() (B) good()
(C) fail() (D) bad()
Q – 5 (A) What are the two methods of opening a file? What is the difference between the [05]
two methods?
OR

Page 3 of 4
Candidate Seat no………….

Q – 5 (A) What is inheritance? What are various types of Inheritance? Explain with diagram. [05]

Q – 5 (B) Volume of Ellipsoid = (4/3) × pi × radius1 × radius2 × radius3. Write a program [04]
having function volume () which takes three float arguments: radius1, radius 2 and
radius3 and returns the volume of an Ellipsoid. Use default argument of 2 for
radius1, 3 for radius2 and 4 for radius3 so that if arguments are omitted then the
volume of Ellipsoid is always 100.48. Write a main ( ) function that gets values
from the user to test this function.
Q – 5 (C) What is the difference between procedure oriented programming and object [05]
oriented programming?
OR

Q – 5 (C) Explain Constant pointer and Pointer to Constant with an example. [05]

Q – 6 (A) Distinguish between Early binding and Late Binding. [02]

Q – 6 (B) List out the various operators which cannot be overloaded. [02]

Q – 6 (C) Explain this pointer with example. [03]

Q – 6 (D) Define a class Hospital having rollno and name as data members and member [07]
function to get and print data. Derive a class Ward from class Hospital having data
members: ward number and member function to get and print data. Derive another
class Room from Hospital having data member bed number and nature of illness and
member function to get and print data. Derive class Patient from Class Ward and
Class Room. In main () declare 5 object of Class Patient and get and display all the
information.

OR

Q – 6 (A) Explain public, private and protected access specifer with example. [03]

Q – 6 (B) Explain Inline function with the help of an example. [04]

Q – 6 (C) Define a class CM having data member float cm and class INCH having data member [07]
float inches. Both the classes have default constructor and member functions to get
and show data. (1 inch = 2.54 cm). Define appropriate member functions such that
they support the statements in main () : CM C; INCH IN; C=IN;

***All the Best***

Page 4 of 4

You might also like