Bonus questions - Units IX to XI


Interview/ viva questions: 

1.      What is meant by operator overloading? Why is it necessary?

2.      What is polymorphism?

3.      Explain run-time polymorphism with an example. Differentiate between run-time and static polymorphism.

4.      What is the meaning of ‘has a’ and ‘is a’ relationship in C++?

5.      What is the need for an abstract class?

6.      What are the operators that cannot be overloaded? Can new operators be defined in C++?

7.      What are the dynamic memory operators in C++? What are the equivalent of malloc and free in C++?

8.      What are streams? How are they useful?

9.      Name some of the predefined streams.

10.  What is the difference between:

·        cin and cout

·        cout and cerr

·        Random access and sequential access

11.  Write a simple program to write and read a character from a file.

12.  How is the file pointer used for random file access?

13.  Write down the syntax of the main function (including its arguments).

14.  If we create a class with no member functions, what are the functions which will be automatically created?

 

Extra Stuff: 

Q.) In the complex numbers class that you had created, overload the + and – operators to add and subtract two complex numbers. 

Q.) In the same complex numbers class, overload the * and / operator to multiply and divide complex numbers. 

Q.) Create a class called ‘string’ which will consist of a character array (of maximum length 80). Overload the + operator such that two string objects will be concatenated. 

Q.) In the same string class, overload the ‘= =’ operator such that we can test whether 2 string objects are equal or not (for comparing use ASCII values/you can also use the ‘strcmp’ function. The overloaded operator function should return a Boolean value just like the normal == operator depending on the comparison). 

Q.) In the same string class, overload the ‘<=’ operator such that we can test whether the left side string object is less than or equal to the right side string object (the function should return a value just like the normal <= operator depending on the comparison). 

Q.) Create a class called person and then derive two classes for teaching faculty and non teaching faculty (for a school). The person class should be an abstract class. 

Q.) Create a file using C++ in which we can store an employee’s details (like name, experience and salary). The user should be able to store as many records as he wants. 

Q.) Write a C++ program to read the employee record file and display the contents. 

Q.) Write a C++ program to check whether a given word is present in a text document. 

Q.) Write a program that obtains the file name from the user through command line argument and returns the number of bytes occupied by the file. 

Q.) Write a program to encrypt a file (using your own algorithm for encryption) and store it in a different file. Write a decryption program that will retrieve the original file contents.


Go back to the Contents Page II


Copyright © 2005 Sethu Subramanian All rights reserved. Sign my guestbook.