C++ freshers questions
- What is Operator, Operand, Expression, Statement in 'C'?
- What is polymorphism?
- What is operator overloading?
- What are templates?
- Declare a void pointer.
- Declare a function pointer which takes a pointer to char as an argument and returns a void pointer.
- Type-define a function pointer which takes a int and float as parameter and returns a float *.
- What does the following C statement do?
- while(*c++ = *d++); assuming c and d are pointers to characters.
- How do you call a C module within a C++ module.
- What is the difference between run time binding and compile time binding? Discuss.
- Compare and contrast C++ and Java.
- Why does C/C++ give better run-time performance then Java?
- Does C++ come with in-built threading support.
- 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? - What is the value of "a" after this?
int (*a) [10]; - What is wrong with this?
main(){
int *ptr;
*ptr=10;
} - 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); - int x = 5;
int y = 7;
What is the value of x and y after the expression y+=x++; - What's the difference between C and C++?
- What does Public and Private mean in C++
- 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
- Whats wrong with: char Str[128]; Str="Bob"; ?
- How do you declare a struct called Date that has integer members M, D, and Y?
- Whats the difference between malloc and calloc?
- Whats does realloc do?
- How can a function have several return values?
- Given: void Foo( int i ) { i =i*10; } and int x=10; Foo(x); , What is the value of x?
- What does Polymorphism mean?
- What is a class, and what is an object (or instance)?
- How would you use cout to output a string called Name and an integer named Age ?
- What does function overloading mean?
- What is name mangeling ?
- For two overloaded functions (same name), how does the compiler determine which one to call?
- What is a default argument for a function?
- Default parameters must be supplied right to left, or left to right?
- What syntax rules are there for creating a constructor and destrucor?
- What is the job of a constructor?
- What is the job of a copy constructor?
- When is a copy constructor invoked?
- What are the 'big 3' member functions for a class?
- What happens if you do not have a copy constructor, and your object is passed by value to a function?
- What operator can not be written for your class?
- Can you create your own operators, like a '$' operator?
- You should be able to write a prototype for all the operators for a class.
- Given MGString S, S2; MGDate D; and S2 = S + D; Which operator+ function would be called: MGDate::operator+ or MGString::operator+
- Can operator functions be overloaded?
- Can operator functions be written outside the class, as non-member functions?
- The Standard C++ new operator throws an exception when out of memory: true or false?
- Many older compilers still permit new to return NULL or 0 when out of memory: true or false?
- You can provide your own new and delete operators for allocations of your class: True or false?
- What is a static member variable?
- Describe the steps needed to implement a static data member
- Sorry, just a mish-mash of topics:
- What does const mean at the end of a function?
- What is a virtual function?
- What is a pure virtual function?
- What is special about a class with a pure virtual function?
- What does static mean for a member variable? For a member function?
- What is the difference between has a and is a ?
- In a base and derived class, whose constructor is called first?
- Whose destructor is called first?
- What is the difference between passing pointers and references?
- What is typeid ?
- What is type_info ?
- What is RTTI?
- What are the three keywords for exception handling?
- Why would you create an exception class?
- Can exceptions be bested?
- Why might a function have a try/catch block?
- You should be familiar with fstream, istream, ostream, and strstream
- What is a template class?
- Why would you write a template class?
- Can template classes be derived from normal classes, and visa-versa?
- Can you name atleast 4 collection classes in the STL ?
- Can you name atleast 2 member functions in each?
- What is an iterator , and where are they defined?
- 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]);
No comments:
Post a Comment