• +91 9971497814
  • info@interviewmaterial.com

Computer Interview Questions Answers

CPlusPlus Interview Questions Answers

Question - 71 : - What is an adaptor class or Wrapper class?

Answer - 71 : - A class that has no functionality of its own. Its member functions hide the use of a third party software component or an object with the non-compatible interface or a non-object-oriented implementation.

Question - 72 : - Anything wrong with this code? T *p = 0; delete p;

Answer - 72 : - Yes, the program will crash in an attempt to delete a null pointer.

Question - 73 : - Write a program that ask for user input from 5 to 9 then calculate the average

Answer - 73 : - #include "iostream.h" int main() { int MAX = 4; int total = 0; int average; int numb; for (int i=0; i<MAX; i++) { cout << "Please enter your input between 5 and 9: "; cin >> numb; while ( numb<5 || numb>9) { cout << "Invalid input, please re-enter: "; cin >> numb; } total = total + numb; } average = total/MAX; cout << "The average number is: " << average << "\n"; return 0; }

Question - 74 : - What is an HTML tag?

Answer - 74 : - Answer: An HTML tag is a syntactical construct in the HTML language that abbreviates specific instructions to be executed when the HTML script is loaded into a Web browser. It is like a method in Java, a function in C++, a procedure in Pascal, or a subroutine in FORTRAN.

Question - 75 : - Define precondition and post-condition to a member function.

Answer - 75 : - Precondition: A precondition is a condition that must be true on entry to a member function. A class is used correctly if preconditions are never false. An operation is not responsible for doing anything sensible if its precondition fails to hold. For example, the interface invariants of stack class say nothing about pushing yet another element on a stack that is already full. We say that isful() is a precondition of the push operation. Post-condition: A post-condition is a condition that must be true on exit from a member function if the precondition was valid on entry to that function. A class is implemented correctly if post-conditions are never false. For example, after pushing an element on the stack, we know that isempty() must necessarily hold. This is a post-condition of the push operation.

Question - 76 : - What are each of the standard files and what are they normally associated with?

Answer - 76 : - They are the standard input file, the standard output file and the standard error file. The first is usually associated with the keyboard, the second and third are usually associated with the terminal screen.

Question - 77 : - What do you mean by inline function?

Answer - 77 : - The idea behind inline functions is to insert the code of a called function at the point where the function is called. If done carefully, this can improve the application's performance in exchange for increased compile time and possibly (but not always) an increase in the size of the generated binary executables.

Question - 78 : - What is pure virtual function?

Answer - 78 : - A class is made abstract by declaring one or more of its virtual functions to be pure. A pure virtual function is one with an initializer of = 0 in its declaration

Question - 79 : - How do you link a C++ program to C functions?

Answer - 79 : - By using the extern "C" linkage specification around the C function declarations.

Question - 80 : - In C++, what is the difference between method overloading and method overriding?

Answer - 80 : - Overloading a method (or function) in C++ is the ability for functions of the same name to be defined as long as these methods have different signatures (different set of parameters). Method overriding is the ability of the inherited class rewriting the virtual method of the base class.

Computer Contributors

krishan
Rajeev Katiyar
Yes Baroda

Share your email for latest updates

Name:
Email:

Our partners