C++ Interview Questions and Answers

Views:
 
Category: Entertainment
     
 

Presentation Description

Adavance c++ interview questions and answers for freshers and experienced. c++ Interview Questions and Answers for Beginners and professionals consists of the most frequently asked questions in c++. This list of frequently asked c# Porgramming interview questions and answers will help you crack your interview.

Comments

Presentation Transcript

slide 1:

11/21/2017 C++ Interview Questions and Answers https://www.iteanz.com/c-interview-questions-3/ 1/54  Login / Register      COURSES SAP CONSULTING BUSINESS INDIVIDUALS BLOG  Search For The Courses Software or Skills You Want to Learn... SEARCH C + + I N T E R V I E W Q U E S T I O N S WHAT IS DIFFERENCE BETWEEN C AND C++ C++ is Multi-Paradigm not pure OOP supports both procedural and object oriented while C follows procedural style programming. In C data security is less but in C++ you can use modi ers for your class members to make it inaccessible from outside. C follows top-down approach solution is created in step by step manner like each step is processed into details as we proceed but C++ follows a bottom-up approach where base elements are established rst and are linked to make complex solutions . C++ supports function overloading while C does not support it. C++ allows use of functions in structures but C does not permit that. C++ supports reference variables two variables can point to same memory location . C does not support this. C does not have a built in exception handling framework though we can emulate it with other mechanism. C++ directly supports exception handling which makes life of developer easy. Learn the most most trending IT Technologies with iteanz. Enrol Now × New Blog Post ✕ We have a new post on our blog that might interest you. Take me there

slide 2:

11/21/2017 C++ Interview Questions and Answers https://www.iteanz.com/c-interview-questions-3/ 2/54 WHAT IS AN OBJECT/INSTANCE Object is the instance of a class which is concrete. From the above example we can create instance of class Vehicle as given below Vehicle vehicleObject We can have di erent objects of the class Vehicle for example we can have Vehicle objects with 2 tyres 4tyres etc. Similarly di erent engine capacities as well. WHAT DO YOU MEAN BY C++ ACCESS SPECIFIERS Questions regarding access speci ers are common not just in c++ interview but for other object oriented language interviews as well. Access speci ers are used to de ne how the members functions and variables can be accessed outside the class. There are three access speci ers de ned which are public private and protected private: Members declared as private are accessible only with in the same class and they cannot be accessed outside the class they are declared. public: Members declared as public are accessible from any where. protected: Members declared as protected can not be accessed from outside the class except a child class. This access speci er has signi cance in the context of inheritance. WHAT IS THE USE OF VOLATILE KEYWORD IN C++ GIVE AN EXAMPLE. Most of the times compilers will do optimization to the code to speed up the program. For example in the below code 1. int a 10 2. while a 10 3. // Do something 4. compiler may think that value of ‘a’ is not getting changed from the program and replace it with ‘whiletrue’ which will result in an in nite loop. In actual scenario the value of ‘a’ may be getting updated from outside of the program. New Blog Post ✕ We have a new post on our blog that might interest you. Take me there

slide 3:

11/21/2017 C++ Interview Questions and Answers https://www.iteanz.com/c-interview-questions-3/ 3/54 p g Volatile keyword is used to tell compiler that the variable declared using volatile may be used from outside the current scope so that compiler wont apply any optimization. This matters only in case of multi-threaded applications. In the above example if variable ‘a’ was declared using volatile compiler will not optimize it. In shot value of the volatile variables will be read from the memory location directly. IN HOW MANY WAYS WE CAN INITIALIZE AN INT VARIABLE IN C++ In c++ variables can be initialized in two ways the traditional C++ initialization using “” operator and second using the constructor notation. Traditional C++ initilization int i 10 variable i will get initialized to 10. Using C++ constructor notation int i10 Implicit conversions are performed when a type say T is used in a context where a compatible type Say F is expected so that the type T will be promoted to type F. short a 2000 + 20 In the above example variable a will get automatically promoted from short to int. This is called implicit conversion/coercion in c++. WHAT IS IMPLICIT CONVERSION/COERCION IN C++ Implicit conversions are performed when a type say T is used in a context where a compatible type Say F is expected so that the type T will be promoted to type F. short a 2000 + 20 In the above example variable a will get automatically promoted from short to int. This is called implicit conversion/coercion in c++. WHAT ARE C++ INLINE FUNCTIONS New Blog Post ✕ We have a new post on our blog that might interest you. Take me there

authorStream Live Help