13
END TERM EXAMINATION THIRD SEMESTER [BCA] DECEMBER 2007 Paper Code: BCA 209 Subject: Object Oriented Programming Time: 3 hours Maximum Marks: 75 Note: Attempt all questions. Internal choice is indicated. Q1 (a) What is Polymorphism? Give one example to explain it. (b) Give two differences between procedural and object oriented programming languages. (c) How garbage collection does take place in C++? Illustrate through an example. (d) What is the size of an empty class? (e) Differentiate between „public‟ and „protected‟ using a suitable example. (f) Give code for a template and explain its functionality. (g) How can we access the private Data Members through friend functions? (h) Define a generic class. Give two examples. (i) Differentiate between „multiple‟ and „multilevel‟ inheritance. Give diagrams to explain the differences. (j) What is debugging? Why is it required? (2.5X10=25) Q2 (a) Write short notes on: (3X2) (i) Abstraction (ii) Function prototype. (b) Illustrate the overloading of NEW and DELETE operator. (6.5) OR Write C++ program to show dynamic memory allocation. Also explain the concept. (6.5) (a) Write short notes on: (6) (i) Nested Classes (ii) Functional and Data decomposition. Q3 (a) Create a class named employee. Allow multiple constructors in the class. Create methods to generate salary and sales report of each employee using these constructors. The program should run and also display the details of at least 25 employees. (6.5) (b) Explain the concept of abstract classes. Give a program to explain this concept. (6) OR (a) Write short notes on: (3X2) (i) Encapsulation (ii) Default arguments and how it is used in function call. (b) Create a class called „student‟. Include member function like enter-stud-details() and display() to input details and hence display details of at least 100 students from console. The program should use concept of dynamic memory allocation. (6.5) Q4 (a) Write short notes on: (6) (i) Classification Vs. Composition hierarchy (ii) Parametric polymorphism b) Write a C++ program to overload an operator to concatenate 2 strings. (6.5) OR (a) Explain aggregation and hybrid inheritance with suitable examples. (6) (b) Give C++ program to show the usage of private, public and protected. (6.5) Q5 (a) Write short notes on: (3X2=6) (i) Persistent objects (ii) Streams and its types b) Give a C++ program to explain the concept of exception handling. (6.5) OR

END TERM EXAMINATION - IITM Helping Hand Notesiitmhelpinghand.webs.com/Papers/Object Oriented... · END TERM EXAMINATION ... Write C++ program to show dynamic memory allocation

  • Upload
    lamthu

  • View
    224

  • Download
    1

Embed Size (px)

Citation preview

Page 1: END TERM EXAMINATION - IITM Helping Hand Notesiitmhelpinghand.webs.com/Papers/Object Oriented... · END TERM EXAMINATION ... Write C++ program to show dynamic memory allocation

END TERM EXAMINATION

THIRD SEMESTER [BCA] DECEMBER 2007

Paper Code: BCA 209 Subject: Object Oriented Programming

Time: 3 hours Maximum Marks: 75

Note: Attempt all questions. Internal choice is indicated.

Q1 (a) What is Polymorphism? Give one example to explain it.

(b) Give two differences between procedural and object oriented programming languages.

(c) How garbage collection does take place in C++? Illustrate through an example.

(d) What is the size of an empty class?

(e) Differentiate between „public‟ and „protected‟ using a suitable example.

(f) Give code for a template and explain its functionality.

(g) How can we access the private Data Members through friend functions?

(h) Define a generic class. Give two examples.

(i) Differentiate between „multiple‟ and „multilevel‟ inheritance. Give diagrams to explain the

differences.

(j) What is debugging? Why is it required? (2.5X10=25)

Q2 (a) Write short notes on: (3X2)

(i) Abstraction (ii) Function prototype.

(b) Illustrate the overloading of NEW and DELETE operator. (6.5)

OR

Write C++ program to show dynamic memory allocation. Also explain the concept. (6.5)

(a) Write short notes on: (6)

(i) Nested Classes (ii) Functional and Data decomposition.

Q3 (a) Create a class named employee. Allow multiple constructors in the class. Create methods to

generate salary and sales report of each employee using these constructors. The program should

run and also display the details of at least 25 employees. (6.5)

(b) Explain the concept of abstract classes. Give a program to explain this concept. (6)

OR

(a) Write short notes on: (3X2)

(i) Encapsulation (ii) Default arguments and how it is used in function call.

(b) Create a class called „student‟. Include member function like enter-stud-details() and

display() to input details and hence display details of at least 100 students from console. The

program should use concept of dynamic memory allocation. (6.5)

Q4 (a) Write short notes on: (6)

(i) Classification Vs. Composition hierarchy (ii) Parametric polymorphism

b) Write a C++ program to overload an operator to concatenate 2 strings. (6.5)

OR

(a) Explain aggregation and hybrid inheritance with suitable examples. (6)

(b) Give C++ program to show the usage of private, public and protected. (6.5)

Q5 (a) Write short notes on: (3X2=6)

(i) Persistent objects (ii) Streams and its types

b) Give a C++ program to explain the concept of exception handling. (6.5)

OR

IITM HELPING HAND

Page 2: END TERM EXAMINATION - IITM Helping Hand Notesiitmhelpinghand.webs.com/Papers/Object Oriented... · END TERM EXAMINATION ... Write C++ program to show dynamic memory allocation

(a) Explain „namespaces‟ and „overriding‟ inheritance with examples. (6)

(b) Write a C++ program to transfer text from file 1 to file 2. These files have first to be created

by the user only. (6.5)

IITM HELPING HAND

Page 3: END TERM EXAMINATION - IITM Helping Hand Notesiitmhelpinghand.webs.com/Papers/Object Oriented... · END TERM EXAMINATION ... Write C++ program to show dynamic memory allocation

END TERM EXAMINATION

THIRD SEMESTER [BCA] DECEMBER 2008

Paper Code: BCA 209 Subject: Object Oriented Programming

Time: 3 hours Maximum Marks: 75

Note: Attempt all questions. Internal choice is indicated.

Q1 (a) Give five main advantages of object oriented programming. Describe each advantage by

giving a suitable example.

(b) Describe the usage of const in C++.

(c) Give an example of a generic class. Explain it.

(d) What is the difference between a default constructor and a copy constructor?

(e) How are virtual functions implemented in C++?

(f) What is multiple inheritance? What are its advantages and disadvantages?

(g) Why should inline functions be used instead of plain old # define macros?

(h) Give an example in the form of code to explain the use of templates.

(i) Why is debugging required? Give suitable examples to justify it.

(j) What is exception handling? What are its uses? (2.5X10=25)

Q2 (a) Write a C++ program to show the concept of inheritance. (4.5)

(b) Write short notes on: (4x2=8)

(i) Information Hiding (ii) Abstraction (with suitable examples/program)

OR

(a) What is polymorphism? How can run time polymorphism be implemented? How is late

binding related to it? Give suitable examples. (6.5)

(b) Give short notes on: (3x2=6)

(i) Dynamic memory allocation (ii) Functional Decomposition

Q3 (a) Create a class called „student‟. Allow multiple constructors in the class, include methods to

generate report-card of marks obtained in 5 subjects. The program should run and display the

results for at least 20 students. The program should use the concept of dynamic memory

allocation. (6.5)

b) Give short notes on garbage collection in C++. (3)

c) How do we allocate multidimensional array using new? (3)

OR

(a) Write a program in C++ to show the concept of metaclass. (4)

(b) How are C++ objects laid out in memory? (4)

(c) Can a programmer free() pointers allocated with new? Can he delete pointers allocated with

malloc()? Explain. (4.5)

Q4 (a) write short notes on:

(i) Method and Parametric Polymorphism.

(ii) Differences between overloading and overriding.

(c) Write a class “linked queries” in C++. This class should have functions for adding or deleting

an item from the queue after necessary checks. The linked queue is not to be implemented

using arrays. (6.5)

OR

(a) Give difference between composition and classification hierarchy using suitable code.(3)

(b) Give a code in C++ to show the concept of operator overloading. (6.5)

IITM HELPING HAND

Page 4: END TERM EXAMINATION - IITM Helping Hand Notesiitmhelpinghand.webs.com/Papers/Object Oriented... · END TERM EXAMINATION ... Write C++ program to show dynamic memory allocation

(c) Name three operators that cannot be overloaded . Give their symbols in C++ also. (3)

Q5 (a) Write a generic swap macro in C. A macro which can swap any type of data (int, char, float,

struct etc.) (5)

(b) Write short notes on: (2.5x3=7.5)

(i) Namespaces and their advantages.

(ii) Difference between multilevel and multiple inheritance.

(iii)Persistant objects.

OR

(a) Write a program in C++ to show the concept of exception handling. How do we change the

string length of an array of char to prevent memory leaks even if someone throws an

exception? (6.5)

(b) Write short notes on: (2x3=6)

(i) File open() and close() syntax.

(ii) Stream and its types.

(iii) Utility of generic class.

IITM HELPING HAND

Page 5: END TERM EXAMINATION - IITM Helping Hand Notesiitmhelpinghand.webs.com/Papers/Object Oriented... · END TERM EXAMINATION ... Write C++ program to show dynamic memory allocation

END TERM EXAMINATION

THIRD SEMESTER [BCA] DECEMBER 2009

Paper Code: BCA 209 Subject: Object Oriented Programming

Time: 3 hours Maximum Marks: 75

Note: Attempt all questions. Internal choice is indicated.

Q1 (a) What is the purpose of the copy constructor? (2.5)

(b) Differentiate between the compile-time binding and run-time binding. (2.5)

(c) Consider the definition of the following function templates: (3)

Template<class X>

X wow (X x,Xy) {return x+y;}

Find and explain the output of the following statements:

(i) Cout<<wow (5,7) <<endl;

(ii) String s1=”sunny”; string s2=”day”; cout<<wow(s1,s2)<<endl;

(d) Write a recursive function to multiply two positive integers using m and n using repeated

additions. (4)

(e) List differences between virtual classes and virtual functions. (3)

(f) What are namespaces? What are their advantages? (3)

(g) What are virtual destructors? Explain and give the suitable examples. (3)

(h) List differences between free()/delete() pair and malloc()/ calloc() pair. (4)

Q2 Attempt any one part of the following:

(a) (i) What are abstract classes? Explain their advantages. How are they created? Show by

suitable examples. (3)

(ii)How does the const differ in C++ from C?

(3)

(iii) Explain the volatile keyword of C++ with suitable example. (2)

(iv) Explain the initialization list method for initialization of classdata members

through the constructors. (4.5)

(b) Create a String class to create empty strings or create strings from other strings passed as

argument to its constructor. Memory allocation for creation and disposal of strings will be

dynamic. The string class will have one char pointer to point the string and member length to

hold the length of this string. Write the- (12.5)

(i) Constructor and destructors for this class.

(ii) Overload the + operator to find the concatenation of strins s1 and s2 into string s3 by

the statement s3=s1+s2.

(iii) Overload the operator < to compare two strings in the statement: if (s1<s2)

(iv) Show() method to print the strings right aligned on the screen.

Q3 Attempt any one part of the following:

(a) (i) Differentiate between aggregation and composition with suitable examples. (3)

(ii) write down the syntax for defining a member function outside the class specification.

How these functions can be made inline? (3)

(iii) Discuss the method and syntax for calling constructors of base classes in multilevel

inheritances with suitable example. Take at least two levels of inheritance. (6.5)

IITM HELPING HAND

Page 6: END TERM EXAMINATION - IITM Helping Hand Notesiitmhelpinghand.webs.com/Papers/Object Oriented... · END TERM EXAMINATION ... Write C++ program to show dynamic memory allocation

(b) Create a matrix class to: (12.5)

(i) Dynamically create a matrix of order mxn.

(ii) To read the elements into it through the keyboards.

(iii) To multiply two matrices of orders mxn and nxp.

(iv) To initialize one matrix from another matrix using the copy constructor.

(v) To delete a matrix explicitly using the destructor.

(vi) To print a matrix on the display.

Q4 Attempt any one part of the following:

(a) (i) Discuss methods to overload the unary, pre-increment++ and post increment++ operators.

(4.5)

(ii) Explain the nested classes with suitable example.

(4)

(iii) What is this pointer? What happens on the execution of the statement: delete this; in

a class. Write a program demonstrating the use of this pointer. (4)

(b) (i) Discuss the ways to convert one object into another object. (3)

(ii) Design classes called polar and rectangle for representing a point in polar and rectangle

systems. Support data conversion functions to support statements such as: rectangle r1,r2;

polar p1,p; r1=p1, p2=r2; (9.5)

Q5 Attempt any one part of the following:

(a) (i) Explain the exception handling mechanism in C++. (4.5)

(ii)Discuss the ostream, istream and other stream classes starting with ios class. (2.5)

(iii) Write a program using class for opening text file and counting the words and lines in it.

(5.5)

(b) (i) Explain the persistent objects. (2)

(ii) Write a generic class to sort n items into ascending order. Items are read through the

keyboard. (4)

(iii) Explain the working of seekg() seekp() tellp() tellg() read() write() bad() good() functions

in stream classes. (6.5)

IITM HELPING HAND

Page 7: END TERM EXAMINATION - IITM Helping Hand Notesiitmhelpinghand.webs.com/Papers/Object Oriented... · END TERM EXAMINATION ... Write C++ program to show dynamic memory allocation

END TERM EXAMINATION

THIRD SEMESTER [BCA] December 2010

Paper Code: BCA 209 Subject: Object Oriented Programming

Time: 3 hours Maximum Marks: 75

Note: Attempt All questions carry equal marks (15 each).

Q1 (a) List the differences between function overloading and overriding. (3)

(b) Differentiate between the new and malloc(). Can delete be used to free memory allocated

using the malloc()? (3)

(c) Explain the procedure to overload the pre-increment and post-increment operators with

suitable examples. (3)

(d) Write a function to return the division of two complex numbers. The real part and imaginary

part could be int, float and double. (4)

(e) Write the characteristics of inline functions. List the differences between inline and macros.(3)

(f) What are abstract classes? Give examples. (3)

(g) What are static data members? Explain and give a suitable example. (3)

(h) Expalin the differences between abstraction and encapsulation. (3)

Q2 (a) (i) What is structured programming? How is it different from the object oriented

programming? (4.5)

(ii) Write a program to calculate the roots of any quadratic equation dealing with

complex roots also and printing them in appropriate form. (4)

(iii) Differentiate between the run time memory management in C++ from C. (4)

OR

(b) Create a time class to perform following operations over time (hh:mm:ss) using 24 hrs.

clock. (12.5)

(i) To create or initialize any object of type time using constructors.

(ii) To find addition of two times using operator overloading. For eg. T1=t2+t3. Or

t1=27+t2; must be valid statements. In the second statement 27 seconds are added to t2.

(iii) Overload the operator> to compare two times. Thus t1>t2 or t1>35 can be compared

resulting the result true or false.

(iv) To print the time in the format hh:mm:ss.

Q3 (a) (i) How are C++ objects created using new stored in the memory? (4)

(ii) Write a program to multiply two matrices. Both matrices order will be entered

through keyboard and are created accordingly at run time. The matrix containing

multiplication is also created at run time. Use the constructors and destructors. (8.5)

OR

(b) (i) Write a program in C++ to illustrate the concept of metaclass. (3)

(ii) Give the advantages of the reference variables over the pointer variables. Under

which situation they should be avoided? (3)

(iii) What are the nameless objects? Why are they used in C++? (3)

(iv) Discuss the ways so that a class can‟t be inherited by any means. (3.5)

Q4 (a) (i) Name the operators and their symbols which can‟t be overloaded in C++? (4)

(ii) Explain the nested classes with suitable example. (4)

(iii) What is this pointer? What happens on the statement: delete this; in a class. Write a

program demonstrating the use of this pointer. (4.5)

OR

(b) (i) What is a copy constructor? Explain with suitable example. (3)

IITM HELPING HAND

Page 8: END TERM EXAMINATION - IITM Helping Hand Notesiitmhelpinghand.webs.com/Papers/Object Oriented... · END TERM EXAMINATION ... Write C++ program to show dynamic memory allocation

(ii) Write a program to support the following statements over strings in C++ (9.5)

1) Int p=”xyz” into p.

2) S1=”hello” +s2; to find concatenation of “hello” and s2 intos1.

3) S1=-s2; to find reverse of s2 into s1.

Q5 (a) (i) Explain the try/catch structure in C++ and its variants from the exception class.(4.5)

(ii) Discuss the hierarchy of stream classes. (3)

(iii) Write a program using class for opening text file and replacing all lowercase letters

to uppercase and vice versa leaving other characters intact.

(5)

OR

(b) (i) Explain the persistent objects. (2)

(ii) Differentiate between the multilevel and multiple inheritances. (4)

(iii)Explain the syntax and working of any six file functions in system classes. (6.5)

IITM HELPING HAND

Page 9: END TERM EXAMINATION - IITM Helping Hand Notesiitmhelpinghand.webs.com/Papers/Object Oriented... · END TERM EXAMINATION ... Write C++ program to show dynamic memory allocation

END TERM EXAMINATION

THIRD SEMESTER [BCA] DECEMBER 2011

Paper Code: BCA 209 Subject: Object Oriented Programming

Time: 3 hours Maximum Marks: 75

Note: Attempt all questions. Internal choice is indicated.

Q 1 (a) What are the advantages of references over pointers? Also, discuss

some of the advantages of pointers over references.

(b) Point out the reasons why using 'new' is a better idea than using malloc().

(c) What is the size of the Empty Class? And why? Also, give an example to print the

size of the empty class.

(d) Design a class from which only one object can be created. If more than one object

is created then the program should terminate.

(e) Which are the three stream classes that commonly used for disk I/O? Also, give

the names of their base classes.

(f) Write a short note on Parameterized constructor.

(g) Give a C++ code/program to explain the use of a static variable.

(h) How can we access the private data members through friend functions?

(i) How Virtual functions are implemented in C++?

(j)What are Abstract classes? Explain with an example. Also, state their advantages.

Q2 (a) What is the principle reason of passing arguments by reference?

Explain with a C++ code. (4)

(b) What is Dynamic memory allocation? How can we achieve Dynamic Memory

allocation in C++? (6)

(c) Write a short note on Functional Decomposition. (2.5)

OR

(a) Define a class to represent a bank account. Data members should include

name_of_the_depositor, account_number, account_type, and the balance. Member

functions to be included: - (8.5)

(i) To assign initial values.

(ii) To display account information.

(iii) To deposit an amount.

(iv) To withdraw an amount after checking for the balance (Whether that much

amount can be withdrawn or not).

Decide about public and private members on your own.

(b) Predict and explain the output of the following programs: - (2x2)

(i) int main()

{

int iarr[]={l0,11,12,13,14};

int I, *p;

for(p=iarr, i=0; p+i<=iarr+4; p++, i++)

{

cout<<*(p+i);

}

cout<<"\n";

IITM HELPING HAND

Page 10: END TERM EXAMINATION - IITM Helping Hand Notesiitmhelpinghand.webs.com/Papers/Object Oriented... · END TERM EXAMINATION ... Write C++ program to show dynamic memory allocation

return 0;

}

(ii) void fun(char *name)

{

name=”John Lennon”;

}

void main()

{ char *name="Bob Dylan";

fun(name);

}

Q3 (a) Write a function power() to raise a number 'm' to a power 'n'. The function takes a

double value for 'm' and int value for 'n' and returns the result correctly. Use a

default value of 2 for 'n' to make the function to calculate squares when this

argument is omitted. Write a main that gets the values of 'm' and 'n' from the user

to test the function. (4)

(b) List some of the special properties of constructor functions. (2.5)

(c) Write short notes on the following:- (6)

(i) Nested classes

(ii) Function overloading v/s Function Overriding

OR

Create a class called "employee" that contains an employee number, employee

name, department name and salary. Include a member function getdata() to get data

from the user for insertion into object; another function putdata() to display t.he data.

Use appropriate constructors. The program should input and printout data for 100

employees. Also, provide the facility of searching an employee record according to

user's choice given as: - (12.5)

(a) Search by employee number

(b) Search by employee name.

Finally display the searched record (if found).

Q4 (a) List the operators which cannot be overloaded with their symbols and

name. (3)

(b) How assignment operator can be overloaded? Illustrate with a suitable

example. (6)

(c) Explain constructors in Derived classes with a suitable example. (3.5)

OR

(a) What is a 'this' pointer? What are its uses? (3)

(b) Write short notes on the following: - (5)

(i) Multilevel v/s Multiple Inheritance.

(ii) Virtual Base Class v/s Virtual Function.

(c) Write a program to implement the concept of Private Single Inheritance. (4.5)

Q5 (a) Write a program using class for opening a text file and counting the

words and lines in it. (5)

(b) Write short notes on the following: - (2.5x3=7.5)

(i) Namespaces and their advantages

(ii) Stream and its types

(iii) Templates

IITM HELPING HAND

Page 11: END TERM EXAMINATION - IITM Helping Hand Notesiitmhelpinghand.webs.com/Papers/Object Oriented... · END TERM EXAMINATION ... Write C++ program to show dynamic memory allocation

OR

(a) Discuss Exception Handling with its mechanism. Write a program which accepts

two integers from the console and throws divide by zero exception if both the

values entered by the user are equal. (8)

(b) Discuss different file modes available in C++ file handling. (4.5)

********

IITM HELPING HAND

Page 12: END TERM EXAMINATION - IITM Helping Hand Notesiitmhelpinghand.webs.com/Papers/Object Oriented... · END TERM EXAMINATION ... Write C++ program to show dynamic memory allocation

IITM HELPING HAND

Page 13: END TERM EXAMINATION - IITM Helping Hand Notesiitmhelpinghand.webs.com/Papers/Object Oriented... · END TERM EXAMINATION ... Write C++ program to show dynamic memory allocation

IITM HELPING HAND