DIPIETE
– ET/CS (NEW SCHEME) – Code: DE70 / DC56
NOTE: There are 9
Questions in all.
· Question 1 is compulsory and carries 20 marks. Answer to Q.1 must be
written in the space provided for it in the answer book supplied and nowhere
else.
· Out of the remaining EIGHT Questions, answer any FIVE Questions.
Each question carries 16 marks.
· Any required data not explicitly given, may be suitably assumed and
stated.
Q.1 Choose the correct or the best alternative
in the following: (210)
a. What is a difference between a declaration and a definition of a variable?
(A) Both can occur multiple times, but a declaration must occur first.
(B) A definition occurs once, but a declaration may occur many times.
(C) A declaration occurs once, but a definition may occur many
times.
(D) Both can occur multiple times, but a definition must occur first.
b. Which of the following is the boolean operator for logical operator AND?
(A) & (B) &&
(C) |
(D) |&
c. The file iostream includes
(A) The declarations of the basic standard input-output library.
(B) The streams of includes and outputs of program effect.
(C) Both of these.
(D) None of these.
d. Which of the following identifiers is invalid?
(A) paper name (B) writer name
(C) type name (D) print name
e. Which one of the following C operators is right associative?
(A) ^ (B) []
(C) = (D) ->
f. Which of the following header file does not exist?
(A) <iostream> (B) <string>
(C) <sstring> (D) <sstream>
g. A function that calls itself for its processing is known as__________.
(A) Inline Function
(B) Nested Function
(C) Overloaded Function
(D) Recursive Function
h. Which of the following is false?
(A) Cout represents the standard output stream in c++.
(B) Cout is declared in the iostream standard file
(C) Cout is declared within the std namespace
(D) None of above
i. Which is not a loop structure?
(A) for (B) do while
(C) while (D) repeat until
j. Strings are character arrays. The last index of it contains the null-terminated character
(A) \n (B) \t
(C) \0 (D) \l
Answer any
FIVE Questions out of EIGHT Questions.
Each
question carries 16 marks.
Q.2 a.
Discuss the basic characteristics of Object Oriented Language programming. (8)
b. What are preprocessor directives? What does #include do? (4)
c. Examine this program and determine the output. (4)
(i) #include<iostream.h>
int main()
{
int a=1,b=1,c;
if (c=(a-b))
cout<<“The value of c is : ”<<c;
return 0;
}
(ii) If myAge, a and b are all int variables. What are their values after :
myAge=39;
a=myAge++;
b=++myAge;
Q.3 a.
Determine the error with the
code fragment? (6)
(i) unsigned short SomeArray[5][4];
for (int i=0;i<=5; i++)
for (int j=0; j<=4; j++)
SomeArray[i][j]=0;
(ii) #include<iostream.h>
int main()
{
int *pInt ;
*pInt=9;
cout<< “The value at pInt : ”<< *pInt;
return 0;
}
b. Write a program to sort an array of 10 elements using WHILE…DO loop.
Use any algorithm. (6)
c. Write a small program that declares an integer and a pointer to an
integer. Now assign the address of the
integer to the pointer. Use the pointer to set a value in the integer variable. (4)
Q.4 a. Declare
a class called Employee with data members: age, yearsOfservice and
salary. Make the data members private and provide public accessor methods
to get and set each of the data members. Write a program with the employee
class that makes two employees: sets their age, yearsOfservice and salary
and prints their values. (7)
b. How is dynamic initialization of objects
achieved? (3)
c. What is a friend function? What are the merits and demerits of using friend functions? (6)
Q.5 a. How do you differentiate between overloading the prefix and postfix increments? Can you overload the operator + for short integers?
(3)
b. Explain
the importance of using friend function in operator overloading with
the help of an example. (3)
c. Write a SimpleCircle class declaration (only) with one member variable:
itsRadius. (10)
(i) Include a default constructor
(ii) A destructor
(iii) Accessor methods for data member itsRadius
(iv) Add a second constructor that takes a value as its parameter and assigns that value as its parameter and assigns that value to itsRadius.
(v) Create a prefix and postfix increment operator for your SimpleCircle class that increments itsRadius.
(vi) Provide
a copy constructor for SimpleCircle.
Q.6 a. When do we make a class virtual? Give an
example. (4)
b. An organization has two types of employees: regular and adhoc.
Regular employees get a salary which is basic + DA + HRA where DA is 10% of basic and HRA is 30% of basic. Adhoc employees are daily wagers who get a salary which is equal to Number * Wage.
Define the various classes, constructors and
destructors. When a regular employee is created, basic must
be a parameter. When an adhoc employee is created wage must be a parameter. Define the member function for
each class. The member function days() updates number of the Adhoc
employee. Write a test program to test the classes. (12)
Q.7 a. How is polymorphism achieved at: (i) Compile time and (ii) Run
time? Give suitable examples. (10)
b. Why do we need Abstract
class? (3)
c. Show the use of multicatch
handlers with an example. (3)
Q.8 a. What is a function
template? Write a function template to find a maximum value from an array. (6)
b. How are template functions overloaded?
Explain with suitable example. (6)
c. Write a template function that swaps the values of two arguments passed to it. In main() use the function with integers and characters. (4)
Q.9 a. What is the difference between:
(i)cin.read() and cin.getline()
(ii)
manipulators and ios member functions (6)
b. What are the two methods of opening a file? Explain with an example. What is the difference between two methods?
(10)