Friday, November 27, 2015

C++ FAQS

FAQ's


1. copy constructor Vs Assignment operator
2. Copy constructor vs assignment operator -using constant members and refrences(intialization list)
3. Why copy constructor takes const refrence objects?
4. what are the const pointer and constant to pointer?
5. Static object and static data members?
6. singleton class? How it could be thread safe?
7. Static data members are stored in which location?
8. what are the data members are stored in Stack and what are they in Heap?
9.  Where are they const char pointer array elements are stored?
10. what are the differences between vector and list?
11. Map internal implementation?(tree)
12.  How to find loops in circuler linked list?
13. fucntion objects and usage?
14. virtual destructor when where?
15. where do you used singlton desgin pattern?
16. where do you used factory menthod and explain?
17. What are the differences b/w primary key and foriegn key?
18. Diffences b/w static and shared library and syntax?(Linux command)
19. valgrind and other memory leak tools(CPunit tool,memcheck)
20. gdb command for thread creation and thread safe?
21. what are the differences b/w mutex and semaphore?
22. Function pointer declaration and where we can use these function pointers?
23. Stack unwinding and how to resolve it?
24. factory method explain?

25. Write an function swap two number without using temp variable?
26. Find out if the number is power of 2?
27.Find the least common ancestor of 2 nodes in a BST?
28.Write a method to replace all spaces in a string with '%20'
29. Check if the binary tree is balanced?
30.Implement an algorithm to find the nth to last element of a singly linked list?
31. substring subtitution code?


1. Explain about singleton ?  (You should explain multi thread safe)
2. In which scenario did you used Abstract factory and why?
3. What is the usage of design patterns?
4. What are the creational, structural and behaviour patterns?
5. How observer will works explain it?
6. Explain decorator and why we go for decorator?

1. How vptr, VTable works in C++?
2. conversion constructor how it works?
3. virtual desctructor how it works? If no virtual keyword which destructor will call?
4. virtual functions and how they overriden in C++?
5. singleton class in C++?
6. Differences between malloc and new opearator?
7. Boost library? How many places you used?
8. what are the places did you used overloaded new operator?
9. Explain the code implementation in Decorator?
10. How observer works in C++?
11. Where did you used Abstract factory DP?
12. where did you used the command DP?
13. what are the differences b/w vector and array?
14. what are the differences b/w vector size and capacity?
15. How to use smart pointer and how to implement it?
16. auto_ptr how to use it and what are the drawbacks using auto_ptr?
17. what is it means account demon?
18. UML diagrams- deployment diagram and usage?
19. class diagram and use case diagrams?
20. Differences sequential diagram vs activity diagrams?
21. Multiple process or threads can we used inside activity diagrams? ( swimlines, fork,join lines)
22. SAS and GMS differnces?
23. VLT power consumption tools?
24.What are the differences b/w vector and list? where we can use these two containers?
25.In boost lib what are the smart pointers used?
26. Difference b/w mutex and binary semaphore?
27.critical section in windows?
28. mutex explain it?
30. explain about pipes and other IPCs?
31. How does the unrelated process will communicate?
32. Explain about FIFOs?
33. Message queues? when will you use Message queues?
34. Messageoutlook?
35.


1. What are the differences b/w structure and union and their allocation status?
2. Why padding required? how to avoid?
3. What is inline function, how to make sure your inline function would be execuated as a inline? (as per compiler instructions)
4.2+3*(2,3) output?
5. 2+3<4?1:0; output?
6. Write a queue implementation using stacks?
7. Write a code for binary search tree with queues?

1. Can I throw an exception from a constructor? From a destructor?
Yes: You should throw an exception from a constructor whenever you cannot properly initialize (construct) an object. There is no really satisfactory alternative to exiting a constructor by a throw.Not really: You can throw an exception in a destructor, but that exception must not leave the destructor; if a destructor exits by a throw, all kinds of bad things are likely to happen because the basic rules of the standard library and the language itself will be violated. Don't do it.

Type Casting in C++

static_cast