Skip to main content

Posts

C++/OOPS Interview Questions With Answers - Part IV.

Here, are some sample questions based on "C++/OOPS Programming language". Read it carefully as these questions will help you in cracking any interview. Question - 16) Which header file is required for creating and manipulating data files in C++? Answer: fstream.h Question - 17) What is an access specifier? Answer: An access specifier is a way to specify the scope and accessibility of members of a class. Access specifiers can be either private or protected or public. Question - 18) How is memory allocated to a class and its objects? Answer: When a class is defined, memory is allocated for its member functions and they are stored in the memory. When an object is created, separate memory space is allocated for its data members. All objects work with the one copy of member functions shared by all. Question - 19) What is the difference between an object and a class ? Answer: An object is an identifiable entity with some characteristics and behavior. It r...

C++/OOPS Interview Questions With Answers - Part V.

Here, are some sample questions based on "C++/OOPS Programming language". Read it carefully as these questions will help you in cracking any interview. Question - 21) What is polymorphism? Explain with an example ? Answers: Polymorphism is the property by which the same message can be sent to different objects of several different classes, and each object can respond to it in a different way depending upon its class. In C++, polymorphism is implemented through overloading . A function name having several definitions that are differentiable by the number of types of their arguments is known as function overloading. For example, float area (float a) { return a * a; } float area (float a, float b) { return a * b; } Question - 22) What is public, protected and private ? Answers: Public, protected and private are access labels in a class . A class provides three access labels namely private, protected and public. A member declared as public is made avai...

C++/OOPS Interview Questions With Answers - VI.

Here, are some sample questions based on "C++/OOPS Programming language". Read it carefully as these questions will help you in cracking any interview. Question - 26) Is prototyping mandatory in C++? Why? Answers: Yes, prototyping is mandatory in C++ . C++ makes it mandatory to ensure proper invocation of functions and prompt error reporting. Question -27) When should a function be made inline? Answers: A function is made inline when: The function is small. The function is not returning any value and contains no return statement. The function does not contain a loop or a switch or a goto. The function does not contain static variables. The function is not recursive. Question - 28) How is a static variable different from a static function? Answers: A static variable has a function scope but the global life time . A static function has a file scope instead of program scope. Question - 29) What is meant by macro? Answers: A macro is a #define f...

C++/OOPS Interview Questions And Answers - Part III.

Here, are some sample questions based on "C++/OOPS Programming language". Read it carefully as these questions will help you in cracking any interview. Question - 11) Why ‘char’ is often considered as an integer data type? Answer: The memory implementation of char data type is in terms of the number code, which is an integer. Therefore, it is said to be another integer data type. Question - 12) What is the difference between structure and class in C++? Answer: A structure is a collection of data while the class is a collection of data and functions . Further, all members are public by default in a structure while all members are private by default in class. Class has greater data security than structure. Question - 13) What is the purpose of ios:app? Answer: The function of ios::app is to retain the previous contents of a file and to append to the end of the existing file contents, rather than truncating them. Question -14) What is the purpose of i...

C++/OOPS Interview Questions With Answers - Part II.

Here, are some sample questions based on "C++/OOPS Programming language". Read it carefully as these questions will help you in cracking any interview. Question - 6) What is a reference variable ? What is its use ? Answer: A reference variable is an alias name for a previously declared variable. The use of it is that is that the same data object can be referred to by two names and these names can be used interchangeably. Question - 7) What are inline functions ? What is the advantage of using them ? How are they declared ? Answer: An inline function is a function upon which the C++ compiler is asked to perform inline expansion, i.e. the compiler is requested to replace every function call with the complete body of the function, rather than generating the function code at each and every position of the function call. The major advantage of inline functions is that it saves on the overhead of a function call. Since the function is not invoked, but its code is r...

C++/OOPS Interview Questions With Answers - Part I.

Here, are some sample questions based on "C++/OOPS Programming language". Read it carefully as these questions will help you in cracking any interview. Question - 1) What is a class? Answer: A class is a group of objects , i.e. data members or member-functions that share common properties and relationships. It represents a group of similar objects. Question - 2) What is an object? Answer: An object is an identifiable entity with some characteristics and behavior. It represents an entity that can store data and its associated functions. Question - 3) List the advantages of object oriented programming? Answer: Object oriented programming has many advantages : Reusability of code. Ease of comprehension. Ease of fabrication and maintenance. Easy redesign and extension. Question - 4) What is meant by ‘call by value’? Answer: In C++, structures can be passed to functions by two methods namely 'by value' and 'by reference'. In 'Ca...

C Programming Interview Questions With Answers - Part XV.

129. What Is A Structure? Answer: A structure is a collection of data in which all the declared members are public by default. Data security is limited in structure. The general format of declaration of a structure is: struct { Member1; Member2; ………………. ………………. Member m; } var; 130. What Are The Differences Between A Structure & A Union? Answer: A structure is a collection of data in which all the declared members are public by default. Data security is limited in structure. Union is almost the same as the structure as structure contains members of different data types. In structure, each member has its own memory location whereas members of unions have same memory locations. We can assign values to only one member at a time in union. 131. How Can Typedef Be Used to Define A Type Of Structure? Answer: typedef is used for defining new data types of structures. The general syntax is: typedef type data_name; Here, type is the data type and data_name is ...