Sunday, 12 March 2017

Software design questions.


Architectural design 

  1. The concepts of push/pull type of pipelines are used in
    1. MVC Architectural Style
    2. Pipe-and-Filter Architectural Style
    3. Broker Architectural Style
    4. Layered Architectural Style
  2. In a distributed system when two remote components exchange data, who is responsible for data transformation and transmission ?
    1. Client Stub
    2. Broker
    3. Skeleton
    4. Bridge
  3. Polymorphism allows
    1. component replacement
    2. late binding of operations
    3. set parameters at startup
    4. early binding of operations
  4. Suppose that you are to design a gmail like mail system. The incoming mails are scanned for different security checks at different level one after other. Each level has its own functionality and depends on input from previous levels.For designing such system, what is the best possible architecture that can be used for this situation.
    1. layered architecture
    2. Microkernel
    3. pipe and filter
    4. model view controller
  5. You are fetching data from a NO-SQL platform where the table structure is quite dynamic. It can change depending on the nature of the data. You wouldn't like to change your application everytime the table structure changes. What's the pattern you should use?
    1. microkernel
    2. broker
    3. blackboard architecture
    4. reflection
  6. A typical component may have some features available for global use but some features are for its personal use. Which quality tactic it is employing ?
    1. Separate interface from implementation
    2. Hide Information
    3. Record Playback
    4. Shadow Operation
  7. Consider a cloud based data centre which runs a VMWare based virtualized platform. You are running an application on top of a MacOS which is essentially a virtual machine running on top of VMWare hypervisor. What role does the MacOS play here ?
    1. adapter
    2. internal server
    3. external servers
    4. microkernel module
  8. If you have to design a system that reads a set of student marks for the last 10 years from a file, on which you need to select fall semester marks, then you need to group these marks based on various subjects, sort these records based on marks, and finally report the sorted marks and a statistical trend analysis (mean, median, etc.). Which architectural style would you prefer
    1. model view controller
    2. blackboard
    3. pipe and filter
    4. Microkernel
  9. A complex portal's user-interface part interacts with a set of web-servers. These web-servers, depending on the request type, routes it to the appropriate application service which process the request. The webserver then returns the response to the user-interface. Here what is the role of the webserver?
    1. blackboard
    2. broker
    3. kernel
    4. controller
  10. Which quality attribute would you consider most important for the development of Google type search query system?
    1. Testability
    2. Performance
    3. Security
    4. Modifiability
  11. You are writing a software for a Robocup tournament where your team, comprising of multiple Robots will play a soccer game with another opponent. What should be your architectural strategy to write the overall controlling software for your robot?
    1. use broker pattern for distributed computing
    2. use reflection pattern for flexibility
    3. use blackboard based design
    4. use microkernel architecture
  12. If you want to create a modular design in C, which of the following C language features represent interfaces ?
    1. Struct keyword
    2. Loop constructs
    3. Header files (.h files)
    4. Union keyword
  13. The observers are associated with ...
    1. MVC Architectural Style
    2. Pipe-and-Filter Architectural Style
    3. Broker Architectural Style
    4. Layered Architectural Style
  14. Writing an exception handling code in any GUI application is an example of
    1. Preventing Ripple effect
    2. Fault Recovery
    3. Fault Detection
    4. Fault Prevention
  15. Consider a database application where you don't want your application to have hard-coded names of the database columns. You also don't want the number of columns to be hard-coded in your application. If the structure of the table is changed, you want your application to adjust it at runtime. What is the architectural pattern you would consider here?
    1. pipe and filter
    2. layered pattern
    3. model view controller
    4. reflection
    5. Microkernel
  16. You need to test the response time of an online shopping system based on an assumption that the access to the system by one customer is independent of another. Furthermore, there is an expected number of access requests using which you need to simulate the access requests fpr testing. What kind of stimulus you should use
    1. periodic access requests
    2. sporadic access requests
    3. fixed number of access requests
    4. stochastic model of access requests
  17. Consider a space-rover system that receives various types of input signals like temperature and pressure of the environment, speed of descend at any given point in time, image of the surface, and wind speed and direction. These inputs are converted into a set of numeric data points for further processing. Based on the speed of descend, it may have to adjust and activate the upward thrust or a parachute. If there is an obstacle, it may have to change its direction so that after falling it does not damage the internal parts. These decisions are difficult to hard-code as a systematic workflow. What architectural pattern would be most appropriate here?
    1. model view controller
    2. pipe and filter
    3. Microkernel
    4. Reflection
    5. blackboard
  18. It is possible to define a concurrency view using the module decomposition. Therefore, concurrency view is not a absolute necessity.
    1. false
  19. A person needs to implement a web based scientific calculator. Here the user interface will display numeric keypad, and mathematical operation buttons like arithmetic (+,-,/,*), scientific and statistical functions. Based upon the operations system calculates the expression at the back-end and provide appropriate output, which kind of architecture pattern is best suitable for this kind of software.
    1. model-view-controller
    2. pipe and filter
    3. none of the above
  20. Which of the following view can be used to analyze the network traffic.?
    1. Concurrency View
    2. Class view
    3. Deployment view
    4. Use case View
  21. Which of the following structure does not describe the static property of a software architecture?
    1. Software deployment structure
    2. Software runtime structure
    3. software management structure
    4. Software code structure
  22. Suppose that you are building an web-based online shopping application. What is(are) the appropriate architectural patterns?
    1. model view controller
    2. pipe and filter
    3. Microkernel
    4. blackboard
    5. layered pattern
  23. Layered architecture style is best suited to develop the software applications which require
    1. the components to be easily replaceable
    2. information separating as a dominant factor
    3. the performance quality as a dominant factor
    4. the high security of its data contents
  24. Which of the following has maximum impact on the performance of the system.
    1. Support User Initiative
    2. Separate User Interface
    3. Support System Initiative
    4. Enhance Concurrency
  25. add
Design patterns 
.. to be added
General 
  1. what is serialize object?
  2. what is serialization and de-serialization ?
  1. Design tic tac toe game.

Thursday, 24 November 2016

Virtual function inside private access specifier.

There will not be any error, see the below mentioned program and output.


#include<iostream>
using namespace std;

class Base
{
    public:
        virtual void displayClassName()
        {
            cout<<"base class"<<endl;
        }
};

class Derived : public Base
{
    private: // notice displayClassName function is private in derived class.
        virtual void displayClassName()
        {
            cout<<"Derived class"<<endl;
        }
};
int main(int argc, char **argv)
{
    Base *ptr;
    Derived obj;
    ptr = &obj;
    ptr->displayClassName();
    return 0;
}

/*
------------------------------------------------------output
$ ./a.exe
Derived class
*/

Thanks for reading it, for more questions please click on this link.

Wednesday, 1 July 2015

C++ interview questions.

Hi All,

It is actually not possible to list out a set of questions and tell that your interviewer will ask questions from that set only, still it is my small initiative, to list out some frequently asked c++ questions.

My request to all readers, please add questions on comment, if I have missed something which you feel is very important.

My aim is whenever anyone wants to go for interview. He/She should not struggle much for c++ language related questions. He/She can just visit here and prepare best for c++ interview questions.

Array -

  1. Why is it recommended to not use array polymorphically, as function parameter? Hint - look at more effective c++ item 3.
  2. How to implement dynamic array? Code - 01,
  3. How you will pass 2-D array to a function argument? Code - 01, 02, 03,

Pointers and reference -

  1. What is the difference between using pointer and reference? Hint - look at more effective c++ item 1.
  2. Reference
    1. Returning reference vs value from overloaded assignment operator. Hint - focus on how many time we will invoke constructor and destructor.
  3. Pointers
    1. We have two functions - void foo(int a); and void foo(char *ptr); and my client code calls it like - foo(NULL); // which foo it supposed to call? Hint - ambiguity, instead use nullptr.
    2. What is smart pointers? implement it. Hint - understand how auto memory type works, what is RAII, use smart pointers in place of raw pointers, so that you will not fall into memory leak condition even exceptions are thrown. Look at more effective c++ item 9, 28.
    3. If we have pointer to array like - int *pInt = new int [4]; and I delete pointer after increment it, like - ++pInt; delete[]pInt; what will happened? Hint - read about control blocks, array of memory have.
    4. What is auto_ptr? Hint - look at more effective c++ item 28, Code 01, .
    5. Why is it recommended to not pass auto_ptr by value? Hint - look at more effective c++ item 28.
    6. Why we should return by reference, while implementing operator *, in auto_ptr? Hint - look at more effective c++ item 28.
    7. What is std::unique_ptr? What is the difference between std::unique_ptr and auto_ptr? Hint - look at effective modern c++ item 18.
    8. What is shared_ptr? Hint - look at more effective c++ item 29
    9. In c++11, can we have shared_ptr pointing to an array? Hint - No, if u want, give your own delete function. Also we can say this is one of the drawback of the smart pointer as they can not detect difference between pointer pointing to object or pointing to an array of object.  
    10. what is week pointer ? 

Casting -

  1. How many type of casting do we have in c++? Hint - look at effective c++ item 27.
  2. When you will use dynamic_cast? real life example.
  3. Tell a condition where you cannot use static_cast.
  4. Why is it recommended to use C++ style of casting over C style of casting in CPP code implementation? Hint - look at more effective c++ item 2
  5. What are basic rule of user defined conversion? Hint - look at more effective c++ item 5
  6. Why is it recommended to minimize casting as much as you can? Hint - look at effective c++ item 27.

String 

  1. Split a string, on the basis of some delimiter. Code - 01, 

C++ general questions -

  1. What is size_t type? Is it platform dependent? Hint - look at effective c++ item 1.
  2. What is preferred among these -> a. pass-by-value b. pass-by-reference, c. pass-by-reference-to-const? Hint - look at effective c++ item 20.
  3. What if you don't return anything from overloaded assignment operator? Hint - you will not be able to perform -> a = b = c =d; For more details look at effective c++ item 10.
  4. What is the difference between structural programming and OOPS?
  5. What is the difference between function overloading and function overriding?
  6. What is name mangling? Is it there in c?
  7. How you will call a c function in c++ code? or How to combine c and c++ code?
  8. What is RTTI? Tell some real time use or RTTI. Hint - look at more effective c++ item 24, Code 01, 02
  9. What is a mutable data member? Hint - look at effective c++ item 3.
  10. Namespace 
    1. What problem does the namespace feature solve?
    2. What is anonymous namespace?
  11. If we are declaring a friend function, what should be the scope of that function? global? or class specific? what is the good practice?
  12. what is functor?
  13. Why is it recommended to prefer, ststic, inline, and enums over #define? Why we should bot replace functions with #define? Hint - look at effective c++ item 2
  14. Why is it recommended to move non-local object to it's own function? or If you have more then one static object, and they have to get construct in some order, how you will make sure, that they get constructed in defined order? Hint - look at effective c++ item 4.
  15. RAII (resource acquisition is initialization)
    1. What is RAII? Hint - look at effective c++ item 13.
    2. How copying behavior works in RAII classes? Hint - look at effective c++ item 14.
    3. Why to provide access to raw pointer in RAII class? What is explicit and implicit conversion in this case and which one is preferred? Hint - look at effective c++ item 15.
  16. What is the problem in mentioned function signature -> process(shared_ptr<className>(new className), priority()); Hint - look at effective c++ item 17.
  17. What is cross DLL problem? Hint - look at effective c++ item 18.
  18. When compiler perform type checking, during compile time or during run time? Hint - look at effective c++ item 41.
  19. What are traits classes? Why we use them? Hint - look at effective c++ item 47.
  20. What is array to pointer decay rule?Are they same - void myFunc(int param[]); and void myFunc(int* param); Hint - look at effective modern c++ item 1.
  21. Extension to previous question, what is function to pointer decay rule? Hint - same as mentioned in question 22.
  22. What is the "volatile" in c++?
  23. Compiler 
    1. How to disable warnings in c++?
    2. Can I use dll build in 2010 in the executable build in 2015?
  24. add

Class -

  1. List out the compiler generated functions for any class. Hint - look at effective c++ item 5.
  2. How you can restrict compile to insert default functions? Hint - there is also another way in c++11, see c++11 questions and also look at effective c++ item 6.
  3. What is rule of 3?
  4. Write a string class or implement your own string class similar to standard string class. Hint - they want to see how you are writing a class which has a pointer (say char *pString). focus on overloaded assignment operator and copy constructor while writing your code. CodeEx01.
  5. How you will handle, self assignment in overloaded assignment operator? Hint - look at effective c++ item 11.
  6. Write the syntax of this pointer. How it looks like? Hint - it is different for const and non const functions.
  7. What will happened when you will delete this pointer? Hint - undefined behavior.
  8. What is object slicing and how to avoid it? Hint - loot at effective c++ item 20, also look at link01.
  9. Initialization
    1. When is it mandatory to use initialization List in C++?
    2. Can a class have a reference variable? If yes, then how you will assign value to reference variable? Hint - use initialization list.
    3. How you will initialize const data member of a class? Hint - look at effective c++ item 2.
  10. Friend
    1. Tell some real scenarios where you have used friend functions. Hint - to overload << operator. CodeEx01.
    2. How to write friend class?
    3. How to instantiate a derived class object, whose base class ctor is private? Hint - use friend function.
    4. Create a singleton class, which is singleton for all, but one specific class can create any number of objects of that singleton class. Hint - use friend function.
  11. Static 
    1. How you will initialize static data member of a class? Hint - look at effective c++ item 2. Code - 01, const static,
    2. What if I declare static data member in header file, and define it there itself? Hint - compilation error. Code - StaticInHeader01,  StaticInHeader02
    3. What is the use of static data member? Hint - it will be visible from all instance of that class. Code 01, 02, 03,
  12. What is the size of empty class?Why at all we create empty class, what is the purpose? What is empty base class optimization (EBO)? Hint - look at effective c++ item 39.
  13. Inline functions
    1. What is inline functions? Detail out the drawbacks and advantage of inline functions. Hint - look at effective c++ item 30.
    2. What is implicit and explicit, inline function declaration?
    3. Can we declare constructor or destructor as inline function? If no, why? Hint - look at effective c++ item 30.
    4. Can we create function pointer of an inline function?
  14. What is composition? How you will implement it? Hint - 

Constructor -

  1. Can we throw a exception from constructor?
  2. What is copy constructor?
  3. What is the difference between deep and shallow copy? Hint - look at effective c++ item 12
  4. When to use copy constructor, in private?
  5. How to inform client that construction of object has failed? Hint - we can set some boolean value isSuccess to false and poisoned the data.
  6. Can we define constructor as virtual function? Hint - no
  7. What is a default constructor? Is that mandatory that compiler will provide default constructor every time if you missed it in your class?
  8. How to restrict compiler from creating default constructor for us? Hint - look at more effective c++ item 4.
  9. Tell some scenarios where we should declare default constructor (zero-argument constructor). Hint - when you are creating array of object and also look at more effective c++ item 4. 
  10. What is a conversion constructor? Hint - single argument constructor will act like, implicit converter, look at more effective c++ item 5.
  11. What is explicit keyword in constructor? Hint - use to solve problem discussed at previous question, look at effective c++ item 24 and more effective c++ item 5.
  12. What will happen when you pass pointer in copy constructor? Hint - not good idea as pointer can be a null pointer. Hint - look at more effective c++ item 1

Destructor -

  1. True or false -> "If base class destructor is virtual, then compiler will insert virtual destructor into derived class."
  2. Can we throw a exception from destructor? or, What will happend if exception occur in destructor? Hint - look at effective c++ item 8 and more effective c++ item 11.
  3. Why do we need virtual destructor? Hint - look at effective c++ item 7.
  4. Is it a good idea to have virtual destructor in base class, when I am inheriting it as private inheritance in by derived class?
  5. Why we declare destructor as pure virtual destructor? Can pure virtual destructor have body? Hint - look at effective c++ item 7.

Operators and operator overloading -

  1. What are conversion operators, and why you should not use them until you have to? Hint - look at more effective c++ item 5.
  2. What is pre-fixed and post fixed operator? overload Increment and Decrements Operator. Hint - look at more effective c++ item 6. This is also a perfect example when it make sense for a function to return const object, and not reference.
  3. In for loop is it ok to use post fix operator ? or Why it is recommended  to use prefix over post-fix? Hint - look at more effective c++ item 6.
  4. Why is it not recommended to overload &&, || , dot (.), comma (,) .. few other as well, operators? Hint - look at more effective c++ item 7. Recommendation - if you don't have good reason to overload any operator don't overload it.
  5. Overload + operator for complex number. It should work for all mentioned case -
    1. complex A, B, C;
    2. c = A + B;
    3. int i = 10;
    4. C = A + i;
    5. C = i + A;
      1. Hint - look at effective c++ item 24.
  6. overload << operator for your class. Code - 01, 02
  7. add
     

Memory management -

  1. How many storage Classes do we have? Hint - link01.
  2. How malloc works? Code - 01, 02, 03, 04,
  3. Can we crate an object from new and delete it from free ?
  4. Overload operator new and delete in global and class scope? Hint - look at more effective c++ item 27.
  5. How free will know the size of object (how much memory it has to free)?
  6. Tell the usage of new, operator new, placement new, delete, operator delete, new[] and  operator new[], in c++. Hint - look at effective c++ item 16 and more effective c++ item 8. Code - Placement new (01,)
  7. How delete[] will know how many objects it has to delete? Hint - look at effective c++ item 16.
  8. Tell some scenarios where you will use placement new.
  9. What is std::new_handler and set_new_handler function? Hint - look at effective c++ item 49.
  10. When it make sense to to overload new and delete operators? Hint - look at effective c++ item 50.
  11. Write class specific new and delete operators. Hint - look at effective c++ item 51 and 52.
  12. Justify statement, "if you have written placement new then you should write placement delete". Hint - look at effective c++ item 52.

Inheritance and Virtual functions (or run-time polymorphism) -

  1. Inheritance 
    1. How many types of inheritance are exist in c++? Hint - Multiple, Multilevel, Hybrid, etc.. 
    2. Justify statement - "if it is inheritance follow is-a model strictly". Hint - look at effective c++ item 32. 
    3. Can we implement inheritance in struct? Hint - Yes
    4. How to make a class, abstract class? What do you mean by abstract class? How you will handle virtual, non-virtual and pure-virtual functions of your base class, into your derived class? Hint - look at effective c++ item 34 and 36
    5. What is Private Inheritance? When we will use it? Hint - look at effective c++ item 39.
    6. What are the differences between private, public and protected inheritance?
    7. When should you use multiple inheritance? Hint - look at effective c++ item 40.
    8. Why run-time polymorphism is very costlier in multiple inheritance? Hint - look at more effective c++ item 24
    9. Describe diamond problem? How you will solve it? Write constructors of all classes.
    10. What is virtual inheritance?
  2. Polymorphism (Virtual) 
    1. What is virtual function and what all things will happens when u create a function as virtual function? Hint - vtbl and vptr.
    2. Why is it recommended to avoid hiding inheritance names? Or names in the derived class will hide the name of base class, under "public inheritance", this is wrong behavior, as public functions of base has to be accessible at any cost.? Hint - In case of overloaded functions. One is virtual and other is non-virtual. Or both are non-virtual. Avoid compilation error in derived class by using derivatives. For more info look at effective c++ item 33.
    3. Can we give definition to pure-virtual function? Hint - look at effective c++ item 34.
    4. We can give by default value to our function parameter, but in the case of inheritance, how it will behave if I give different. by default value, to same function parameter while function overriding? Hint - look at effective c++ item 37.
    5. What is the difference between template class (implicit interface or compile time polymorphism) and virtual class ( explicit interface)? Hint - look at effective c++ item 41.
    6. How we were achieving dynamic binding without virtual? Hint - through functions pointers, in call back function.
    7. What will happen if I call virtual function, from constructor or destructor? Hint - look at effective c++ item 9.
    8. What is vtbl? will derived class's vtbl hold the function pointers of base class's virtual function? 
    9. How vptr pointer looks like? internals (or say syntax).
    10. Can we declare inline virtual functions? Hint - look at effective c++ item 30 and more effective c++ item 24
    11. What will happened when you have run-time polymorphism but you didn't declare destructor as virtual and delete base class pointer?
    12. What if my derived class has virtual function in private? AnsHint - also look at effective c++ item 35, code.
    13. What is the cost of virtual functions and RTTI? Hint - look at more effective c++ item 24.
  3. add

Templates -

  1. Can template class contain virtual or pure-virtual functions ? Hint - Yes.
  2. Can a template class contains template virtual function? Hint - No.  
  3. Detail out all usage of typename. What is nested dependent name? Hint - look at effective c++ item 42.
  4. What is the difference between typename (Hint - need not to be a class)and class (Hint - for classes and structures)in template programming ? Hint - look at effective c++ item 42.
  5. Why we cannot access template base class's function directly in template derived class? Hint - in the derived class templates, refer to names in base class templates via (this pointer) -> or by using using declarative or via scope resolution operator. For more details look at effective c++ item 43.
  6. What is template specialization? When we use it? Hint - look at effective c++ item 43.
  7. Tell drawback of using template? or What is code bloat? Hint - look at effective c++ item 44.
  8. How to implement generalized copy constructor? Hint - look at effective c++ item 45
  9. Justify statement - "implicit conversion via constructor call is not considered during template argument deduction". Hint - Rational<int> result = first * 2; //error, extension to question number 5 of operators and operator overloading (mentioned above) look at effective c++ item 46.
  10. Can we give definition to friend function (non-member function) inside the class? Hint - look at effective c++ item 46
  11. What is template meta-programming?

Exception handling -

  1. What exception safe functions guarantee you and how you will achieve it? Hint - look at effective c++ item 29.
  2. What will happened between try and catch block ? Hint - stack-unwinding 
  3. What is Stack Unwinding in C++?
  4. How to catch all exceptions?
  5. List out some of standard exceptions. Hint - look at more effective c++ item 13.
  6. How does throwing and catching exceptions differ from using setjmp and longjmp?
  7. How you will deal a situation where your constructor has potential to throw an exception? Remember if constructor throws exception, it will become half constructed object and compiler will not invoke destructor on half constructed object. Hint - look at more effective c++ item 10.
  8. What are difference between function call and catch statement? Hint - look at more effective c++ item 12.
  9. Why throwing by copy will create 2 objects, and create object slicing problem? Hint - look at more effective c++ item 12 and 13.
  10. What is re-throw? Hint - it will solve the issue mentioned in problem #8, look at more effective c++ item 12.
  11. Why is it not recommended to catch exception by pointers or base class type and recommended to catch it through reference? Hint - look at more effective c++ item 12 and 13.
  12. Is implicit conversion allowed during catch the exception? Hint - look at more effective c++ item 12.
  13. What is exception specification? Hint - loot at more effective c++ item 14.
  14. What will happened if function void foo() throw(); actually throw exception? Hint - undefined behavior could lead to core dump. Code - 01,
  15. How you can set your own unexpected exception handler? Hint - use set_unexpected(UserDefinedFunctionName) , loot at more effective c++ item 14.
  16. What is the cost of exception? Hint - look at more effective c++ item 15.
  17. Implement no-throw swap, function. Hint - look at effective c++ item 25

I/O -

  1. Print the last K lines of an input file.

Achieve efficiency in c++ 

  1. Know about 80-20 rules. Hint - look at more effective c++ item 16.
  2. What is lazy loading and how we will implement that? Hint - look at more effective c++ item 17.
  3. What is Eager evaluation, how to implement it in c++? Hint - look at more effective c++ item 18. 
  4. What is the cost of temporary object? In what all scenarios they will get created? How you can reduce it? Hint - look at more effective c++ item 19.
  5. What will happen when you pass char array[] to string parameter? Hint - look at more effective c++ item 19.
  6. Will temporary object creation take place during implicit type conversion? If yes, then how you can avoid that? Hint look at more effective c++ item 21.
  7. What is return value optimization? Hint - look at more effective c++ item 20.
  8. How we can minimize the compiler dependencies between files? Hint - look at effective c++ item 31

Techniques (or jugad, in hindi) in c++

  1. Can we have virtual constructors in c++? no! Hint - you can think of factory method design pattern as virtual constructors, and we can mimic them here, to have a feel of virtual constructors (have clone functions). look at more effective c++ item 25. Code VirtualConstructorError, VirtualConstructorThroughClone
  2. How to make non-member function, act like virtual function? Hint - take base class object as function parameter, and perform public operation through that object, while will intern do things polymorphically, for more look at more effective c++ item 25. Code - NonMemberAsVirtual
  3. How can you implement your class such a way, it creates 0 or 1 object only? Or How to limit the number of objects of your class? Hint - if you make constructor private, no object shall be created by client or think of singleton design pattern, look at more effective c++ item 26. Code SingleObj, K-NumOfObjectsOnHeap, K-NumOfObjectsOnStack, K-NumOfObjectsOnHeapNoOneInherit, K-NumOfObjectsOnHeapOutSideClass, CountingBaseClass
  4. How to make a class like no one can inherit it? Hint - look at effective c++ item 39 more effective c++ item 26 + this link. Code - NoInheritance,  
  5. How to make a class which can only create its object on heap (only through new)? If I try to create simple object on stack, it should give me compilation error. Hint - look at more effective c++ item 27, other link, Code OnlyInHeap, 
  6. Once you achieve heap based object implementation, you ristrict your class to being inherited or be part of other class as composition, how would you solve this problem. Hint - look more effective c++ item 27. Code - ,
  7. How to create a class which can allow object creation only on stack not on heap (aposit of question-5). Hint - look at more effective c++ item 27. Code - OnlyInStack, 
  8. After achieving object creation only on stack, you will face same issue, like what will happened in the case of inheritance, will client be able to create derived class object on heap?
  9. Use of proxy classes. Hint - look at more effective c++ item 30. 
  10. How to overload operator [][], to display two dimensional array? Code - OverloadOperator
  11. How to detect operator [], is getting used to display a value or update the value? Code - ReadOrWrite
    1. int arr[MAX];
    2. cout << arr[0] // display
    3. arr[0] = 10 // update
  12. How you can tell operator [] is getting used for read or write operation? Hint - look at more effective c++ item 30.
  13. How you can make function virtual, in the respect to more then two objects? Hint - look at more effective c++ item 31
  14. What is p-impl idiom? Hint - look at effective c++ item 25 and 29. 
  15. Detail out the alternatives to virtual function. Or What is non-virtual interface idiom (NVI)? Hint - look at effective c++ item 35.

Call backs

  1. What do you understand by function pointers? How to declare and use them? Code - 01
  2. Can we call two different function, who has same function signature through one function pointer? Code - 01

Good practice to follow -

  1. Make interface easy to use correct and hard to use incorrect. Hint - look at effective c++ item 18.
  2. How to design your class? Hint - look at effective c++ item 19.
  3. Declare data member in private. Hint - look at effective c++ item 22
  4. If you are library developer, exposing non-member , non-friend function to client code, will give you more flexibility. Hint - look at effective c++ item 23.
  5. Postponed variable definition as long as possible. Hint - look at effective c++ item 26.
  6. Don't return the handler to any private data member of a class. It will also help you in multi-threading environment, specially when you want to put mutex on that data member. Hint - look at effective c++ item 28.

C++11 -

  1. General c++11 concepts.
    1. What is uniform initialization in c++ 11?
    2. How initializer_list<T> works, and when we use it? Code 01,
    3. what is move, how it works? 
      1. List out all default compiler generated functions in c++11.
      2. Write the function signature of move. Hint code 01, 02
      3. Will copy constructor gets created if you have defined move constructor? Or how to make your object not copyable?
      4. Will move constructor gets created if I create copy constructor? Reverse of previous question
    4. How auto works?
      1. What is auto keyword in c++ 11? How does it useful? Hint - look at effective modern c++ item 5. 
      2. How compiler detect the type of auto? How auto type detection is different from template type detection? Can template type detection, detect initializer_listHint - look at effective modern c++ item 2
        1. How type detection are different in below mentioned cases -
            1. Case - 1
              1. const char name[] = "R. N. Briggs";
              2. auto arr1 = name;
              3. auto& arr2 = name;
            2. Case - 2
              1. void someFunc(int, double);
              2. auto func1 = someFunc;
              3. auto& func2 = someFunc;
      3. What is the difference between below mentioned two loops, when we use what? -
        1. for(const auto& i: arr) {...}
        2. for(auto i: arr) {...}
          1. Hint - look at the output of auto by value and auto by reference programs.
      4. Why is it not recommended to use auto with std::vector<bool> return type? What is explicit typed initializer idiom? Hint - effective modern c++ item 6.
    5. Why we use bind in c++?
    6. What is std::function? Hint - a new way of writing function pointers. Code 01, 02
    7. How constexpr works?
      1. Is constexpr always guaranteed to be on compile time?
    8. Can we use delete keyword, to indicate compiler not to generate default functions?
    9. How to force compiler to generate its default function? Hint use - default keyword.
    10. Can I delegate other constructor from any constructor in c++11? Hint - use initialization list , code 01,  
    11. What is enum class? How it works? Hint - added scope resolution operator.
    12. How to make my class, such that no one can inherit from it? Hint use final keyword.
    13. What you we mean by final virtual function ?
    14. Lambda expression
      1. How we can remove functor? Hint - by using Lambda expression 
      2. How to capture all local values in lambda? Hint - use [=]
      3. How you will capture all local values by reference in lambda? Hint - use [&]
      4. How you mention the return type of lambda? Hint -  []() -> bool {}
    15. Literals
      1. Can we have user defined Literals? For ex - height = 3.4cm; hre cm is user defined literals. Hint - usae operator""
      2. What is the limitations of c++ literals? Hint - it works with few primitive data types.
    16. loops
      1. Write enhanced version of for loop.
      2. for_each
    17. override keyword 
      1. When to use override keyword?
      2. What problem override keyword solves, which we has in c++03?
    18. universal reference
    19. Universal reference
      1. What is R-value reference? What is the difference between R-value reference and universal reference? Hint - Code 01,
      2. Can we overload function on the basis of L-value reference and R-value reference?
      3. What is perfect forwarding? Hint - we use it with template, and forward to other function. std::forwared<T>(arg), Code 01,
      4. What is the difference between std::forwared and std::move? Hint - code 01,
    20. When to use remove_refence? And how it works? Hint - Code 01,
    21. nullptr
      1. What is the difference between NULL and nullptr?

    22. add
  2. Template
    1. How compilier detect template types in below mentioned 3 conditions - (Hint - look at effective modern c++ item 1)
      1. Parameter type is a pointer or reference type.
      2. Parameter type is a universal reference.
      3. Parameter type is neither a pointer nor a reference (by value).
    2. What is decltype? When do we use it? How its value changes with the use of operator () ? Hint - look at effective modern c++ item 3.
    3. How you will ensure that the type being deduced is the type you expect? Hint - look at effective modern c++ item 4.
  3. string literal 
  4. add

C++ 14 -

  1. Can we deduct return type of a function from auto? What is the syntax difference when we use decltype to detct the type of function's return value between c++11 and c++14? Hint - look at effective modern c++ item 2 and 3.

STL -

  1. What is the difference between size and capacity in linear containers like vector?
  2. What is the difference between set and map?
  3. What is the different between multimap and map?
  4. What is the difference between map and unordered_map?
  5. What is associative array? How you will implement it?
  6. How you will have a function that can handle any stl container and iterate through it?
  7. How you will delete the value from stl container?
  8. How you can insert a value in map and be sure that value get inserted ? means there will a possibility there is another value already there, so map will not insert new value with same key ?
  9. What insert function will return in MAP container.
  10. Is it possible to have user define key in MAP? Hint - overload > operator.
  11. Added to previous question, is there any other way, we can achieve user defined key but dont overload > operator?
  12. How to use pair<T,T> as key in MAP?  
  13. What is the different between list and vector?
  14. Can we have vector of references?


Multithreading -

  1. Questions on multitheading concepts - 
    1. What do you understand by mutual execution?
    2. What is the difference between process and thread?
    3. How many threads we shall create for our application?
    4. How many types of thread do we have?
    5. What do you understand by join and detach?
    6. How conditional variable works, give some example?
    7. Can we assign weight to threads? If yes, then how we will do it?
    8. Difference between Mutex and Semaphore?
    9. Implement Mutex.
    10. Implement Semaphore.
  2. Questions on Multithreading based implementations - 
    1. Producer-consumer-problem: We will have many producer threads and many consumer threads. Like event driven system, as and when any event occur, your producer thread will create event and add them into event buffer (or queue), your consumer threads will act on those event and respond properly. How you will design the system, as your queue will be shared between producer and consumer.
    2. Read-write-problem: You have common data structure, where many read-write threads access that DS, while updating the data it should not allow reader threads to read it and any number of reader threads can read the data simultaneously.
    3. Suppose you have hundreds of threads, to serve many client request. Design a thread scheduler, and demonstrate how you are going to handle all resources.
    4. You have 3 threads, T1, T2 and T3. How you will make-sure that T1 gets executed first, then T3 and then T2?  Or how you will implement a sequential execution in multi-threading environment?
  3. C++ Specific 
    1. What is future and promise?
    2. What is the difference between std::atomic<bool> type and std::atomic_flag type?
  4. add