Wednesday, September 29, 2010
Model Paper
1. What are the merits of OOP?
2. Compare cin and cout.
3. What are enumerated data types?
4. What is the use of scope resolution operator?
5. List different methods of calling functions.
6. What is the advantage of creating inline functions?
7. Give the syntax of overloading a unary operator with an example.
8. List the operators which cannot be overloaded.
9. Describe any three types of inheritance with examples.
10. Explain new and delete memory management operators.
11. Explain this pointer with an example.
12. Why do we need virtual function?
13. What is late binding?
14. What is a c++ stream?
15. What is the use of tellg() and seekg() functions?
Section B: Answer any 6 questions 6 x 5 = 30
1. Explain the usage of switch statement with example.
2. Explain the difference between structures and unions.
3. With an example, explain how do you create an array of objects?
4. Explain the meaning of different access specifiers.
5. Explain the usage of default arguments in functions with an example.
6. Give the advantages of inheritance.
7. Explain with an example, how you create space for an array of objects using pointers.
8. Explain the use of command line arguments with an example
Section C : Answer any 3 questions 3 x 10 = 30
1. a) What is function overloading?
b) Write a program to implement overloading of functions with default arguments, to find the factorial of a number.
2. a) What are constructors?
b) Write a program to copy a string using constructors.
3. a) What is operator overloading?
b) Write a program to add two complex numbers using the concept of operator overloading.
4. Describe different levels of inheritance with examples.
5. Create a student database using the concept of files. Include the following fields.
Name, Reg-No, Attendance
Enter data for 10 students and output the same in proper format.
Friday, September 24, 2010
Difference between Overloading and over riding
available in the same class where as in overridding,there
is relationship between a super class method and subclass
method.
2. overloading doesn't block inheritence from the
superclass where as overridding blocks inheritence.
3. in overloading,seperate methods share the same name
where as in overridding,subclass methods replaces the
superclass.
4.overloading must have different method signatures where
as overriding must have same signature
C++ Questions
Programming in C++
1) Output for code below will be
class sample
{
public:
sample( ) {
cout<<"constructed";
throw 1; }
~sample( ) { cout<<"destructed:"; }
};
int main( )
{
try
{
sample s;
}
catch(int x){ cout<<"caught:"; }
return 0;
}
a) compile time error
b) constructed destructed caught
c) constructed caught
d) caught
2) following statement/statement are true about namespace in c++
a) avoids name clashes.
b) can be extend over multiple header files.
c) Controls the name visibility.
d) None of above
3) following statement / statements are true about static
a) maintains the value for variable across the function calls
b) specifier for internal linkage
c) used to with classes to declare sharable data
d) all of above
4) following statement / statements are true about function template
a) it allows explicit specialization
b) it doesn’t allow for partial specialization
c) it never allows for default arguments
d) it allows full specialization
5) Consider a class having int* i, floa* j, float m, static int x as data members and
void f1( ), static void f2( ) as member functions. In a simple object model layout, size of the object will be
a) 24 bytes
b) 12 bytes
c) 4 bytes
d) 16 bytes
assume VC++ compiler and 32 bit computing.
6) following statement/statements are true about static methods of a class
a) can access only static members
b) called through class name & ::
c) can be used for overloading operators in a class
d) only a & b
7) class A has two int data members and one static int member. It has two virtual functions void f1( ) and void f2( ). Class B is derived from A having one double* member. The size of object of B class will be
a) 16 bytes
b) 28 bytes
c) 24 bytes
d) 20 bytes
8) following statement/statements are true about constructors in C++
a) initialize object
b) you can have literal virtual constrcutor
c) inherited to derived class (subclass)
d) you can write static constructors to initialize static members of class
9) following statement/statements are true about destructors in C++
a) destructors can be virtual
b) destructor can be called explicitly in case of automatic storage, like constructor
c) destructors can be overloaded like constructor
d) they are called by delete operator
10) following statement/statements are true about visitor design pattern
a) creating the objects
b) makes adding new operation easy
c) code reusability
d) accumulating state of objects
11) following statement/statements are true about template method design pattern
a) define the skeloton of an algorthim in an operation, deffering some steps to subclass.
b) technique for code reuse
c) controls the object accessibility
d) abstract out the object creation details
12) consider the following code, the o/p is
class A
{ public: A( ){ cout<<”A”;} };
class B: public A
{ public: B( ){ cout<<”B” ;} };
class C
{ public: C( ) {cout<< ”C”;}
private:
B bb;
};
int main( )
{
C cc;
}
a) ABC b) CBA c) BC d) CAB
13) Following provides RTTI
a) dynamic_cast b) typeid & type_info c) both d) reinterpret_cast
14) following statement/ statements are true about VTABLES in C++
a) generated by compiler at compile time
b) VTABLES are pointed by VPTR in object
c) Only one VPTR for each object in all scenarios of inheritance
d) generated by compiler at run-time
15) To share the object in memory by different client objects, following memory management technique is used
a) copy-to-write
b) reference counting
c) singleton
d) all of above