Freshers Aptitude technical questions
Freshers Job Alert
Bookmark and Share

Technical Interview Questions
Core Java Java & EJB Oracle Cobol
C with answers C++ .Net Pythin
ASP .Net Ruby Java More...

Technical Questions , C & C++

 

Below are few C & C++ related interview questions which is frequently asked in interview.This C & C++ interview questions are only meant for C & C++ skilled candidates.

Please send us if you have different interview questions.

  1. What is Operator, Operand, Expression, Statement in 'C'?
  2. What is polymorphism?
  3. What is operator overloading?
  4. What are templates?
  5. Declare a void pointer.
  6. Declare a function pointer which takes a pointer to char as an argument and returns a void pointer.
  7. Type-define a function pointer which takes a int and float as parameter and returns a float *.
  8. What does the following C statement do?
  9. while(*c++ = *d++); assuming c and d are pointers to characters.
  10. How do you call a C module within a C++ module.
  11. What is the difference between run time binding and compile time binding? Discuss.
  12. Compare and contrast C++ and Java.
  13. Why does C/C++ give better run-time performance then Java?
  14. Does C++ come with in-built threading support.
  15. Class A derives B derives C. All have foo(). I cast C to A and call foo(). What happens?

    All classes A, B, C have default constructor, foo() that calls parent foo() and allocates 100 bytes to their own private local variable, and a destructor that frees the 100 bytes. I create a C object and then destroy it. What's the problem? Did all the memory get freed? What if I create C, cast to A, and then destroy it. How would I make sure memory is freed? (destructor must be "virtual" and each destructor must call parent destructor)

    What errors are caught at compile time vs link time?
  16. What is the value of "a" after this?
    int (*a) [10];
  17. What is wrong with this?
    main(){
    int *ptr;
    *ptr=10;
    }
  18. Given int n, i=10, j=20, x=3, y = 100;
    What is the value of n and y at the end of each of the following expressions?
    a) n = (i > j) && (x < ++y);
    b) n = (j - i) && (x < y++);
    c) n = (i < j) || (y+=i);
  19. int x = 5;
    int y = 7;
    What is the value of x and y after the expression y+=x++;
  20. What's the difference between C and C++?
  21. What does Public and Private mean in C++
  22. Is it possible to keep 2 stacks in a single array, if one grows from position one of the array, and the other grows from the last position. Write a procedure PUSH(x,s) that pushes element x onto stack S, where S is one or the other of these two stacks. Include all necessary error checks
  23. Whats wrong with: char Str[128]; Str="Bob"; ?
  24. How do you declare a struct called Date that has integer members M, D, and Y?
  25. Whats the difference between malloc and calloc?
  26. Whats does realloc do?
  27. How can a function have several return values?
  28. Given: void Foo( int i ) { i =i*10; } and int x=10; Foo(x); , What is the value of x?
  29. What does Polymorphism mean?
  30. What is a class, and what is an object (or instance)?
  31. How would you use cout to output a string called Name and an integer named Age ?
  32. What does function overloading mean?
  33. What is name mangeling ?
  34. For two overloaded functions (same name), how does the compiler determine which one to call?
  35. What is a default argument for a function?
  36. Default parameters must be supplied right to left, or left to right?
  37. What syntax rules are there for creating a constructor and destrucor?
  38. What is the job of a constructor?
  39. What is the job of a copy constructor?
  40. When is a copy constructor invoked?
  41. What are the 'big 3' member functions for a class?
  42. What happens if you do not have a copy constructor, and your object is passed by value to a function?
  43. What operator can not be written for your class?
  44. Can you create your own operators, like a '$' operator?
  45. You should be able to write a prototype for all the operators for a class.
  46. Given MGString S, S2; MGDate D; and S2 = S + D; Which operator+ function would be called: MGDate::operator+ or MGString::operator+
  47. Can operator functions be overloaded?
  48. Can operator functions be written outside the class, as non-member functions?
  49. The Standard C++ new operator throws an exception when out of memory: true or false?
  50. Many older compilers still permit new to return NULL or 0 when out of memory: true or false?
  51. You can provide your own new and delete operators for allocations of your class: True or false?
  52. What is a static member variable?
  53. Describe the steps needed to implement a static data member
  54. Sorry, just a mish-mash of topics:
  55. What does const mean at the end of a function?
  56. What is a virtual function?
  57. What is a pure virtual function?
  58. What is special about a class with a pure virtual function?
  59. What does static mean for a member variable? For a member function?
  60. What is the difference between has a and is a ?
  61. In a base and derived class, whose constructor is called first?
  62. Whose destructor is called first?
  63. What is the difference between passing pointers and references?
  64. What is typeid ?
  65. What is type_info ?
  66. What is RTTI?
  67. What are the three keywords for exception handling?
  68. Why would you create an exception class?
  69. Can exceptions be bested?
  70. Why might a function have a try/catch block?
  71. You should be familiar with fstream, istream, ostream, and strstream
  72. What is a template class?
  73. Why would you write a template class?
  74. Can template classes be derived from normal classes, and visa-versa?
  75. Can you name atleast 4 collection classes in the STL ?
  76. Can you name atleast 2 member functions in each?
  77. What is an iterator , and where are they defined?
  78. Name atleast 3 algorithm templated functions.

    What are the major differences between C and C++?

    •  What are the differences between new and malloc ?

    •  What is the difference between delete and delete[] ?

    •  What are the differences between a struct in C and in C++?

    •  What are the advantages/disadvantages of using #define ?

    •  What are the advantages/disadvantages of using inline and const ?

    What is the difference between a pointer and a reference?

    •  When would you use a pointer? A reference?

    •  What does it mean to take the address of a reference?

    What does it mean to declare a function or variable as static ? What is the order of initalization for data? What is name mangling/name decoration?

    •  What kind of problems does name mangling cause?

    •  How do you work around them?

    What is a class?

    •  What are the differences between a struct and a class in C++?

    •  What is the difference between public, private, and protected access?

    •  For class CFoo { }; what default methods will the compiler generate for you>?

    •  How can you force the compiler to not generate them?

    •  What is the purpose of a constructor? Destructor?

    •  What is a constructor initializer list?

    •  When must you use a constructor initializer list?

    •  What is a:

    •  Constructor?

    •  Destructor?

    •  Default constructor?

    •  Copy constructor?

    •  Conversion constructor?

    •  What does it mean to declare a...

    •  member function as virtual ?

    •  member function as static ?

    •  member function as static ?

    •  member variable as static ?

    •  destructor as static ?

    •  Can you explain the term "resource acquisition is initialization?"

    •  What is a "pure virtual" member function?

    •  What is the difference between public, private, and protected inheritance?

    •  What is virtual inheritance?

    •  What is placement new ?

    •  What is the difference between operator new and the new operator?

    What is exception handling?

    •  Explain what happens when an exception is thrown in C++.

    •  What happens if an exception is not caught?

    •  What happens if an exception is throws from an object's constructor?

    •  What happens if an exception is throws from an object's destructor?

    •  What are the costs and benefits of using exceptions?

    •  When would you choose to return an error code rather than throw an exception?

    What is a template? What is partial specialization or template specialization? How can you force instantiation of a template? What is an iterator? What is an algorithm (in terms of the STL/C++ standard library)? What is std::auto_ptr ? What is wrong with this statement? std::auto_ptr ptr(new char[10]);