Microsoft Interview Question
Software Engineer / DevelopersTeam: GTSC
Country: India
Interview Type: In-Person
Answer_1
When a program encounters a situation that was not expected, there are three different behaviors the program could exhibit:
-Sometimes programs crash. A crash is when a program quits unexpectedly.
-Sometimes programs return an exception. An exception is an unexpected error that does not result in the program quitting.
-Sometimes programs hang. A hang is when a program remains open and fails to respond to input by the user.
Ans_2(Source stackoverflow)
-Inline replaces a call to a function with the body of the function, however, inline is just a request to the compiler that could be ignored (you could still pass some flags to the compiler to force inline or use *always_inline* attribute with gcc).
-compilers can also inline expand some recursive functions; recursive macros are typically illegal.
-A macro on the other hand, is expanded by the preprocessor before compilation, so it's just like text substitution, also macros are not type checked, inline functions are. There's a comparison in the wiki.
-For the sake of completeness, you could still have some kind of type safety with macros, using gcc's __typeof__ for example, the following generate almost identical code and both cause warnings if used with the wrong types:
Ans_5
Late_binding :Late binding is a runtime process of looking up a declaration, by name, that corresponds to a uniquely specified type. It does not involve type checking during compilation, when referencing libraries, including an object, is not required.The term ‘dynamically linked’ means that the program and the particular library it references are not combined together by the linker at link time.Late binding's main disadvantages are:
-Slowed application performance.
-Does not provide code completion benefits, versus early binding.
Late binding is generally used in scenarios where an exact object interface is unknown at design time.
Early_binding:The term ‘statically linked’ means that the program and the particular library that it’s linked against are combined together by the linker at link time.
Difference between crash and exception in c++ -
- kanhaiya.baranwal October 08, 2014Exceptions are defined situations which c++ can manage and handle.
Some undefined behaviors like null pointer dereferencing is not handled through exception, and so causes the program to crash.