Blogroll

C + + Questions for Campus Placement Preparation - 2

Saturday, 26 May 2012


Question: What are Virtual Functions?Years: Virtual member function is a function Declared in the base class functions on Whose is redefined (same function name) by icts derived class. To implement Implements a virtual function function name preceded with Simply keyword virtual.Declared A virtual function in the base class Represents the single interface and Its redefinition by the derived class implements operations Specific To Each derived class.Question: What is a Namespace?
Ans: A namespace is a declarative Region That ties a year-to-any additional identifying names Declared inside it. It overcomes the problem of name conflicts (of variable functions, classes or types) That may occour Independently Developed functions. It is Possible to use the Sami name in separate namespaces without conflict APPEAR Even If the names in the Sami translation unit. It allows to group entities like classes, objects and functions Under a name.

Question: Explain The Need for "Virtual Destructor".
Years: Virtual destructor is needed to make destructor as Dynamically bounded. When we destroy object of a derived class with non-virtual destructor Explicitly, only destructor of base class is Executed and not of the derived class. Reason of non-performance of the derived class Is That the compiler uses static binding When calling the destructor.Can Be Overcome this problem by making the destructor To Be Dynamically bounded Which is possible, by making the destructor virtual base class of.

Question: Can We Have private constructor in a class?
Ans: Yes. When we want that object of a class Can Be created only from inside the class then we Can Have private constructor.

Question: What is the use of Operator Overloading?
Years: Operator overloading is a property of Giving additional meaning-so to Existing operator That Cdn THEY work with variables of user-defined data types in addition to aussi Specific built-in data types.
Major uses of operator overloading are:
(I) It Enhances the capability of Existing operators by making 'em to work on user-defined data types in addition to built-in data types.
(Ii) It is broad and complex Used in Programs Involving Multiple objects of different classes as it has Provides interface to a common operator.

Question: What is the Difference between hand and new malloc ()?
Years: New operator allocates memory and call the constructor of the class Whereas malloc () allocates memory only.

Question: What is the Difference between delete and hand free ()?
Ans: Delete operator calls the destructor and then deallocates memory Whereas free () deallocates memory only and not call the destructor?

Question: What is the Difference between object and a class year?
Ans: Object is a year with entity identification, with Some Characteristics and Behavior Whereas class is a group of objects That Have common properties and relationship. In Fact objects are variables of data type class.

Question: What is the Difference between class and structure?
Years: Major Differences Between a class and a structure are:
(I) Class is collection of objects of similar objects Whereas structure is collection of members of different data types.
(Ii) By default all the members inside the class are private Whereas all declarations inside a structure are public by default.
(Iii) The structures are value types and the classes are reference types.
(Iv) Classes Can Be Whereas inherited structures Cdn not be.
(V) Fields Can Be directley instanciated but not in classes.

Question: What is a scope resolution operator?
Ans: For the ease of use, Some member function (Generally lengthy) are in the class goal Declared They Are Defined outside the class. Such function now to bind with class scope resolution operator (denoted as ::) is used. It Is That year operator informe compile That The Given is a function of a class member function has-beens Even Though Defined outside the class.

Question: What is name mangling?
Ans: Name mangling is a technical for calling compile Used by overloaded function by Changing Their names
.
Question: What is function overloading and operator overloading?
Years: Function overloading is a property by a family of Which performing similar functions related activity share a multiple common name (but different arguments). When a function is overloaded Called, It Is The Responsibility of the compiler to select the function Appropriate DEPENDING upon the number of arguments.
Operator overloading is a property of Giving additional meaning-to an existing operator so it is That Defined For Some user-defined data-types in addition to icts Earlier Defined data types. It Does not change the original meaning-of the operator, it extends the Existing injustement of the functions on this operator.

No comments:

Post a Comment

 

Most Reading

Tags

Sidebar One