C++ Interview Question: What is "strstream”?
Answer: Class that reads and writes to an array in memory
C++ interview question: Can we generate a C++ source code from the binary file?
Answer: Technically this is possible, but in my knowledge their no such software available yet. Why this is possible? In program flow we do like this to generate binary file. High level language programming code -low level programming code- hex code- binary code. How we can do reverse can be illustrated with this example. When I type 0 on screen the ASCII equivalent is 65 and so the binary code will be by converting 65 (01010 0101) so I can recognize this and decode this. Same technique can be used. Some secret mission defense org. I heard have this code splitter from binary to assembly language (low level language)/ Converter type devices available, they use them for secret national purpose.
C++ interview question: Explain "passing by value", "passing by pointer" and "passing by reference"
Answer: There is major difference between these three are when we want to avoid making the copy of variable and we want to change value of actual argument on calling function. There are we use passing by pointer, passing the reference. We can not perform arithmetic operation on reference.
C++ interview question: Difference between "vector" and "array"?
Answer: Vector and Array List are very similar. Both of them represent a 'grow able array', where you access to the elements in it through an index.Array List it's part of the Java Collection Framework, and has been added with version 1.2, while Vector it's an object that is present since the first version of the JDK. Vector, anyway, has been retrofitted to implement the List interface.The main difference is that Vector it's a synchronized object, while Array List it's not.While the iterator that are returned by both classes are fail-fast (they cleanly throw Concurrent Modification Exception when the original object has been modified), the Enumeration returned by Vector are not.Unless you have strong reason to use a Vector, the suggestion is to use the Array List.
C++ interview question: What are the types of STL containers?
Answer: deque
hash_map
hash_multimap
hash_multiset
hash_set
list
map
multimap
multiset
set
vector
C++ interview question:Difference between a "assignment operator" and a "copy constructor"
Answer :Copy constructor is called every time a copy of an object is made. When you pass an object by value, either into a function or as a function's return value, a temporary copy of that object is made. Assignment operator is called whenever you assign to an object. Assignment operator must check to see if the right-hand side of the assignment operator is the object itself. It executes only the two sides are not equal
C++ interview question: Can we have "Virtual Constructors"?
Answer: No, we cannot have virtual constructors. But if the need arises, we can simulate the implementation of virtual constructor by calling a Init method from the constructor which, should be a virtual function.
C++ interview question: Explain the need for "Virtual Destructor".
Answer: In case of inheritance, objects should be destructed exactly the opposite way of their construction. If virtual keyword is not added before base class destructor declaration, then derived class destructor will not at all be called. Hence there will be memory leakage if allocated for derived class members while constructing the object.
0 comments:
Post a Comment