C++ Interview Questions and Answers: A Comprehensive Guide

C++ Interview Questions and Answers

Basic Concepts

Ques: 1 Can derived class exceptions also be caught by the catch block?

Ans:

No

Ques: 2 What Is a B-Tree?

Ans:

The B-tree was invented in 1972 by R. Bayer and E. McCreight and was designed from the start to create shallow trees for fast disk access. Shallow trees have few “levels”. We have to seek through them fewer times, and therefore they run quickly. Because seeks often require going to disk for the information we need, the performance increase with a shallow tree rather than a deeper tree can be substantial. B-trees are a powerful solution to the problem of disk-based storage; virtually every commercial database system has used variations on a B-tree for years. A B-tree consists of pages. Each page has a set of indices. Each index consists of a key value and a pointer. The pointer in an index can point either to another page or to the data you are storing in the tree. Thus, every page has indices that point to other pages or to data. If the index points to another page, the page is called a node page; if the index points to data, the page is called a leaf page.

Ques: 3 What is Parsing Numeric Expressions?

Ans:

Numeric expressions are generally represented by the infix notation, in which the operator is placed between the operands and parentheses are used where necessary to indicate the order in which the operators are applied to the expressions. Numeric expressions are best computed using a postfix notation also called reverse polish notation, in which the operator is placed after its two operands and parentheses are not required.

Ques: 4 What is Parsing? And tell me how many types of Parsing?

Ans:

Parsing is a generic operation that identifies legal expressions and breaks them up into a form suitable for further processing. Parsing has applications in many different fields such as computer science, interpreting human language, and so on. The main goal of parsing is to check the validity of an expression and make more sense out of it. The term “grammar” is commonly used in programming languages to identify legal expressions. There are two approaches commonly used during parsing of these two methods:

  • Top-down approach: This method looks at the program first and recursively identifies parts that are eventually matched to the input expression.
  • Bottom-up approach: This method looks at the input expression and combines the pieces of the expression to make a legal program from it.

Ques: 5 What is Quadratic Probing?

Ans:

The performance problem encountered by linear probing is caused by the cluster buildup that occurs as a result of the probing sequence. Quadratic probing uses a different sequence to avoid primary clustering.

Ques: 6 What is Bucket Addressing?

Ans:

The bucket addressing technique is similar to chaining in that collision resolution is performed by using additional space. Whenever instead of using linked lists, we make use of buckets. A bucket can be defined as a block of space that can be used to store multiple elements that hash to the same position. In this method, we must give the buckets a fixed size; the choice of this size can sometimes be tricky. Collisions are still possible because you may fill a bucket completely—in which case the key must be stored somewhere. This storage location can be an available bucket or an overflow area. A variation can be used to eliminate the need for buckets with fixed size: We can allow each bucket to contain a pointer to a dynamically allocated array.

Ques: 7 What is chaining?

Ans:

The chaining technique basically looks at the hash table as an array of pointers to linked lists. Each slot in the hash table is either empty or simply consists of a pointer to a linked list. You resolve collisions by adding the elements that hash to the same slot to the linked list to which that slot points. At the same time, deletions are easy. You simply delete elements from the linked list.

Ques: 8 What is the Hash Function?

Ans:

The hash function is an important part of the hashing technique. This function is used to transform the keys into table addresses. The hash function we choose should be easy to compute and should be able to transform the keys into integers in the range 0 to TR-1. Because most of the commonly used hash functions are based on arithmetic operations, we should convert the keys to numbers on which arithmetic operations can be performed.

Ques: 9 What Is Recursion?

Ans:

Recursion is when a thing refers to itself or to an image just like itself. For a function, recursion means that the function calls itself. For an object, recursion is when the object refers to things like itself by means of a pointer or a reference. Often, recursive structures and recursive functions go hand in hand. The best way to do many of the common operations on recursive structures is to use a recursive function.

Ques: 10 What are Heap Operations?

Ans:

A heap is a sequence in which the element with the largest value is always the first element in the sequence. Elements are pushed into and popped out of the heap only at the front of the sequence. The STL priority queue is usually implemented as a heap. The Standard Library provides two heap-to-sequence conversion operations and two heap element access operations.

Ques: 11 What’s the requirement of Input Iterator?

Ans:

An input iterator is an iterator that must satisfy the following set of requirements:

  • Default Constructible: The iterator must have a default constructor so that it can be created without initializing it to any particular value. When an input iterator is created using its default destructor, it is an invalid iterator. It remains invalid until it is assigned a value.
  • Assignable: The iterator must have a copy constructor and an overloaded assignment operator. These features allow for copying and assigning values to iterators.
  • Equality Comparable: The iterator must have an overloaded equality operator == and an inequality operator !=. These operators allow for the comparison of two iterators.

Ques: 12 What are The Multimap Containers?

Ans:

A multimap is similar to a map except that elements can have duplicate keys. Even the multimap class has a similar class definition to the map container class, with some exceptions. It has no subscripting operators because there may be more than one element that has the same key value. The insertion operation is always okay because duplicate keys are allowed.

Ques: 13 What is the The Deque Container?

Ans:

A deque is basically a type of vector. It is like a double-ended vector. It inherits the vector container class’s efficiency in sequential read and write operations. But in the case of addition, the deque container class provides optimized front-end and back-end operations. These types of operations are the same as implemented they are in the list container class, where memory allocations are engaged only for new elements. This feature of the deque class eliminates the need to reallocate the whole container to a new memory location, as the vector class has to do. Even deques are ideally suited for applications in which insertions and deletions take place at either one or both ends, and for which sequential access of elements is important.

Ques: 14 What does the term Memory Leaks mean?

Ans:

The term memory leak is quite popular in the industry, but it isn’t often explained. Here’s the idea: If you allocate memory using new and fail to reclaim that memory using delete, the memory is irretrievably lost until your program ends. It is as if the memory “leaked out” of your program.

Ques: 15 What does the term Utility Classes mean?

Ans:

A utility class is basically a class that contains grouped functionality but no persistent data members or attributes. Although utility classes are not part of standard C++, some programmers like to create them. The UML offers support for them. The purpose of a utility class is to take a set of functionality and group them together in a common class. There is no need to create an instance of this class because each function in the class is declared static: We can simply use the functions contained in the class by fully qualifying the desired function name.

Ques: 16 What is Realization?

Ans:

A realization is a type of relationship. It is a relationship between two model elements, in which one model element (or the client) realizes the behavior that the other model element (or the supplier) specifies. A realization is displayed in the diagram editor as a dashed line with an unfilled arrowhead towards the supplier.

Ques: 17 What is the class diagram?

Ans:

Class diagrams are basically used to explain the classes in terms of diagrams. They serve two purposes:

  • To represent the static state of classes
  • To exploit the relationships between those classes.

In the early stages of the software development life cycle, it is important to note that the class diagram model attempts not only to define the public interface for each class but to define the associations, aggregations, and generalizations defined between the individual classes.

Ques: 18 What’s the use of Interaction Diagrams?

Ans:

Interaction diagrams are basically used for the models’ behavior when models are working in several objects in a use case. They are represented as how the objects collaborate for the behavior. Interaction diagrams do not give an in-depth representation of the behavior. If we want to know what a specific object is doing for several use cases, use a state diagram. Then we got particular behavior over many use cases or threads, use an activity diagram.

Ques: 19 What are Interaction Diagrams?

Ans:

Interaction diagrams are basically a type of model. Models behavior of use cases by describing the way groups of objects interact to complete the task. And the two kinds of interaction diagrams are sequence and collaboration diagrams. In this case, that can dramatically improve the documentation and understanding of the interaction.

Ques: 20 What are the Limitations of CRC Cards?

Ans:

CRC Cards are very useful, but they also have many limitations:

  • They have inherent limitations.
  • They also don’t capture the interrelationship among classes.
  • The nature of the collaboration is not modeled well.
  • CRC cards also don’t capture attributes.
  • CRC cards do not capture this information.

Ques: 21 What are CRC Cards?

Ans:

CRC basically stands for Class, Responsibility, and Collaboration. A CRC card is nothing more than a 4×6 index card. This is a very simple, low-tech device that allows you to work with other people in understanding the primary responsibilities of our initial set of classes. We assemble a stack of blank 4×6 index cards and meet around a conference table for a series of CRC card sessions. CEC cards are used to identify classes, responsibilities, and collaborations between the objects in an object-oriented system.

Ques: 22 What are Visualizations?

Ans:

Visualization is basically a way of presentation. It’s just a fancy name for the diagrams, pictures, screenshots, prototypes, and any other visual representations created to help through and design the graphical user interface of your product.

Ques: 23 What does the term Association mean?

Ans:

Association basically called as a third party which creates a relationship commonly captured in the domain analysis is a simple association. An association suggests that two objects know of one another and that the objects interact in some way. An association is mainly a structural relationship that indicates that objects of one classifier, which classifier is a class and interface, that are connected and can navigate to objects of another classifier.

Ques: 24 What is generalization?

Ans:

Generalization is basically a type of inheritance. But it is different from each other. Generalization mainly describes the relationship; inheritance is the programming language. It is the implementation of generalization—it is how we manifest generalization in code. Generalization implies that the derived object is a subtype of the base object. It has one type of account which is called a checking account. It is a bank account. Its relationship is symmetrical: Bank account generalizes the common behavior and attributes of checking and savings accounts.

Ques: 25 What does the term Modelling Language mean?

Ans:

Modeling language is basically a type of artificial language. It is mainly used for expressing information or knowledge or system in a structure that is defined by a consistent set of rules. The rules are used for the interpretation of the meaning of components in the structure. It is used for mainly some purposes:

  • Graphical modeling languages use basically diagram techniques with named symbols that represent concepts and lines that connect the symbols and that represent also relationships and various other graphical annotations to represent constraints.
  • Textual modeling languages typically use standardized keywords accompanied by parameters to make computer-interpretable expressions.

Ques: 26 What is a constructor initializer list?

Ans:

Constructor Initializer List is basically used for some valid values. Its main purpose is to initialize the data members with some valid values. This can be done in two ways:

  • To initialize a const
  • To initialize a reference

Ques: 27 What is an iterator?

Ans:

An iterator is basically a type of object that represents a stream of data. Unlike a sequence, an iterator can only provide the next item. The for-in statement uses iterators to control the loop, and iterators can also be used in many other contexts.

Ques: 28 What is virtual inheritance?

Ans:

Inheritance can be private, public, or virtual. With virtual inheritance, there is only one copy of each object even if the object appears more than once in the hierarchy.

Ques: 29 Can you define destructor as static?

Ans:

No, because destructors are called implicitly by the compiler upon exit from the scope. Static functions can only be called explicitly. The destructor is a member function of a class which is used to destroy an object of a class. The destructor has the same name as the class name but is preceded by a tilde (~). The destructor takes no arguments and has no return type. It is called automatically when an object goes out of scope or is explicitly deleted.

Ques: 30 What is placement new?

Ans:

The placement-new operator constructs an object on a pre-allocated buffer. The pre-allocated buffer has to be allocated on the heap. Operator new allocates memory from the heap, on which an object is constructed. Standard C++ also supports the placement new operator, which constructs an object on a pre-allocated buffer. This is useful when building a memory pool, a garbage collector, or simply when performance and exception safety are paramount.

Ques: 31 What is multithreading?

Ans:

Multithreading is defined as the task of creating a new thread of execution within an existing process rather than starting a new process to begin a function. It is the ability of an operating system to concurrently run programs that have been divided into subcomponents or threads.

Ques: 32 What is the difference between a static link library and a dynamic link library?

Ans:

Many differences are there:
Static Link Library: Static linking is basically a type of method. It is the original method used to combine an application program with the parts of various library routines. The linker is given your compiled code, containing many unresolved references to library routines.
Dynamic Link Library: Dynamic linking is basically a type of method. It is the original method used to combine an application program with the parts of various library routines. The linker is given your compiled code, containing many unresolved references to library routines.

Ques: 33 What are smart pointers?

Ans:

A smart pointer is a type of pointer, but it’s smart. It is an abstract data type that simulates a pointer while providing additional features, such as automatic garbage collection. Smart pointers have very important features in pointers, and their additional features are intended to reduce bugs caused by the misuse of pointers while retaining efficiency. Smart pointers typically keep track of the objects that point to them for the purpose of memory management.

Ques: 34 Why is PCM used?

Ans:

We know that PCM is digital. A more general reason would be that digital signals are easy to process by cheap standard techniques. PCM is basically used for other processes:

  • Filtering
  • Sampling
  • Quantizing
  • Encoding

Ques: 35 What is pulse code modulation?

Ans:

Pulse code modulation is described as PCM. Nowadays, we know it’s a digital world. In this time, it is the heart of technology in communications. It’s a process in which analog signals are converted to digital form. The analog signal is represented by a series of pulses and non-pulses. At this stage, to fully understand, we can refer back to the notes on signals.

Ques: 36 What is the difference between a static link library and a dynamic link library?

Ans:

Basic differences are there:

  • Static libraries are linked at compile time.
  • Dynamic libraries are linked at runtime.

Ques: 37 Name the operators that cannot be overloaded?

Ans:

The names of operators are there which cannot be overloaded:

  • sizeof
  • .
  • .*
  • ->
  • ::
  • ?:

Ques: 38 What is the difference between a class and a structure?

Ans:

Many differences are there:
In C, a structure is basically used to bundle different types of data types together to perform a particular functionality. But in the case of C++, it extended the structure to contain functions also. The major difference is that all declarations inside a structure are by default public. And we are talking about the class. It is a successor of Structure. By default, all the members inside the class are private.

Ques: 39 How do you access the static member of a class?

Ans:

We can access the static member of the class with this syntax: ::

Ques: 40 What are the defining traits of an object-oriented language?

Ans:

The defining traits of an object-oriented language are:

  • Encapsulation
  • Inheritance
  • Polymorphism

Ques: 41 What is a nested class?

Ans:

A nested class is basically a normal class which is enclosed within the scope of another class. It is mainly declared within the scope of another class. The name of a nested class is local to its enclosing class. Unless you use explicit pointers, references, or object names, declarations in a nested class can only use visible constructs, including type names, static members, and enumerators from the enclosing class and global variables.

Ques: 42 What is the Standard Template Library (STL)?

Ans:

STL is basically a standard library of templates which is approved by the ANSI C++ specification. Its library contains many templates which are also approved by them. A programmer who launches into a discussion of the generic programming model, iterators, allocators, algorithms, and such has a higher-than-average understanding of the new technology that STL brings to C++ programming.

Ques: 43 What are the advantages of inheritance?

Ans:

Advantages of inheritance are:

  • It permits code reusability.
  • It saves time in program development.
  • It encourages the reuse of proven and debugged high-quality software, thus reducing problems after a system becomes functional.

Ques: 44 What is the difference between a pointer and a reference?

Ans:

Many differences are there:

  • References are aliases to variables, or we can say another name to a given variable, even though a pointer holds the address of a particular variable.
  • A reference can be thought of as a special type of pointer with certain restrictions.
  • We can create the array of pointers, but it’s not in the case of references.
  • We can use pointer to pointer, but we can’t use reference to reference.
  • We can assign NULL to the pointer, but in references, we can’t.
  • References have to be initialized at the time of declaration and cannot be changed in the code later, whereas this doesn’t hold true with the pointer.

Ques: 45 What is an explicit constructor?

Ans:

An explicit constructor is basically a conversion constructor always declared with the explicit keyword. The compiler does not use an explicit constructor to implement an implied conversion of types. Its purpose is reserved explicitly for construction.

Ques: 46 What’s an initializer list?

Ans:

A constructor initializer list is basically a syntactical construct. It allows the user to specify to the compiler how to initialize member variables of a class upon construction of an instance of that class.

Ques: 47 What’s the difference between a struct and a class?

Ans:

Many differences are there in struct and a class. Class members are private by default, but in the case of structs, members are by default public. And the class is a C++ element, and struct is a C one. We can have functions, virtual functions, inheritance, different access modifiers (private, protected, public) in a class but probably not in a struct. A struct generally holds member variables only.

Ques: 48 When would you use private inheritance?

Ans:

Many uses of private inheritance:

  • It can introduce unnecessary multiple inheritance.
  • It allows members of Car to convert a Car* to an Engine*.
  • It allows access to the protected members of the base class.
  • It allows Car to override Engine’s virtual functions.
  • This makes it slightly simpler to give Car a start() method that simply calls through to the Engine’s start() method.

Ques: 49 Why is iostream better than stdio?

Ans:

Iostream is better than stdio like that:
The iostream library offers two major advantages compared to C’s:

  • It can be extended to support user-defined types.
  • It’s type-safe.

If a programmer can give a complaint about having given poorer performance and a bloated, unintuitive interface.

Ques: 50 What are the problems with a tree-style hierarchy?

Ans:

A tree-style hierarchy is a type of method, and a system is provided for generating a tree-style graphical representation that depicts simultaneously hierarchical and non-hierarchical interrelationships among a set of entities. Two sets of specifications are acquired. One set describes a set of hierarchical interrelationships. The other set describes a set of non-hierarchical interrelationships among the same set of entities. Based on the two sets of specifications, the generated tree-style graphical representation is displayed, as a graphical user interface, on a display device.

Ques: 51 What is a mutable member?

Ans:

It is a type of member which can be modified by the class even when the object of the class or the member function doing the modification is const.

Ques: 52 What is the difference between an external iterator and an internal iterator? Describe an advantage of an external iterator.

Ans:

An internal iterator is working step by step. It’s implemented with member functions of the class. An external iterator is implemented as a separate class that can be”attache” to the object that has items to step through.
An external iterator has the advantage that many different iterators can be active simultaneously on the same object.

Ques: 53 What’s the auto keyword good for?

Ans:

At the end of the object scope, it declares an object with automatic storage duration. Which object will be destroyed. Many variables in functions that are not declared as static and not dynamically allocated have automatic storage duration by default. Local variables are local, but they are not declared within a scope; they are often called automatic variables because they automatically come into being when the scope is entered and automatically go away when the scope closes. The keyword auto makes this explicit. It is never necessary to declare something because local variables are default.

Ques: 54 What is abstraction?

Ans:

Abstraction is basically a type of process. It is the process of hiding the details and exposing only the essential features of a particular concept or object.

Ques: 55 What is a friend function?

Ans:

It’s not actually a member of the class. It can access only private and protected members of the class. The function acts as a friend to a class. As a friend of a class, it must be listed in the class definition.

Ques: 56 Why are arrays usually processed with a for loop?

Ans:

It is basically using for traversing the index of the array. That’s the real power of arrays, accessing each element with the same expression a[i]. All that is needed to make this work is an iterated statement in which the variable a[i] serves as a counter, incrementing from 0 to a.length – 1.

Ques: 57 Can you think of a situation where your program would crash without reaching the breakpoint which you set at the beginning of main()?

Ans:

When main() isn’t invoked, C++ allows for dynamic initialization of global variables. It is possible that global initialization will invoke some function. When main() is not entered, this function crashes, and the crash will occur. Non-static const data members and reference data members cannot be assigned values; instead, we should use an initialization list to initialize them.

Ques: 58 How can you tell what shell you are running on a UNIX system?

Ans:

When we can do the echo RANDOM, then we got a return of an undefined variable.

  • If we are from the C-Shell, we will just get the return value prompt.
  • If we are from the Bourne shell, and in a 5-digit random number.
  • If we are from the Korn shell. We could also do a ps -l and look for the shell with the highest PID.

Ques: 59 Define a constructor – What it is and how it might be called (2 methods).

Ans:

A constructor is a type of member function in the class, with the name of the function being the same as the class name. It also specifies how the object should be initialized.
There are two ways of calling a constructor:

  • Automatically by the compiler when an object is created. It is called an implicitly method.
  • Calling the constructors explicitly is possible, but it makes the code unverifiable.

Ques: 60 What is a node class?

Ans:

A node class is a class that is defined as:

  • Relies on the base class for services and implementation
  • Provides a wider interface to the users than its base class
  • Relies primarily on virtual functions in its public interface
  • Depends on all its direct and indirect base classes
  • Can be understood only in the context of the base class
  • Can be used as a base for further derivation
  • Can be used to create objects

A node class is a class that has added new services or functionality beyond the services inherited from its base class.

Ques: 61 What is the difference between an ARRAY and a LIST?

Ans:

Many differences are there:

  • An array is a collection of homogeneous elements, but in the case of a list, it’s a collection of heterogeneous elements.
  • For an array, memory allocated is static and continuous, but for a list, memory allocated is dynamic and random.
  • For an array, the user need not have to keep track of the next memory allocation, but in a list, the user has to keep track of the next location where memory is allocated.

Ques: 62 What are the conditions that have to be met for a condition to be an invariant of the class?

Ans:

Conditions are there:

  • The condition should hold at the end of every constructor.
  • The condition should hold at the end of every mutator (non-const) operation.

Ques: 63 What is a scope resolution operator?

Ans:

A scope resolution operator is defined as (::). It can be used to define the member functions of a class outside the class.

Ques: 64 What do you mean by binding of data and functions?

Ans:

Binding of data and functions is basically called encapsulation.

Ques: 65 What are 2 ways of exporting a function from a DLL?

Ans:

Two ways are there:

  • Taking a reference to the function from the DLL instance.
  • Using the DLL’s Type Library

Ques: 66 How can a base pointer access the members of a derived class?

Ans:

A base pointer can only point to the object of the derived class, but it cannot access the members of the derived class.

Ques: 67 What is a constructor or ctor?

Ans:

A constructor is mainly used to create an object and initialize it. It’s also used to create a vtable for virtual functions. It is not a method. It is different from other methods in a class.

Ques: 68 What is the difference between a template and a macro?

Ans:

The macro is expanded without any special type checking. It’s expanded by the preprocessors. And it will show up in expanded form during debugging. If a macro parameter has a position-incremented variable (like C++), the increment is performed two times because compiler error messages will refer to the expanded macro, rather than the macro definition itself.

Ques: 69 What are Extern Storage Classes?

Ans:

The extern storage class is basically a static variable whose definition and placement are determined when all object and library modules are combined or linked to form the executable code file. It can be visible outside the file where it is defined.

Ques: 70 What are Static Storage Classes?

Ans:

The static storage class is basically a variable that is known only in the function that contains its definition but is never destroyed and retains its value between calls to that function. It exists from the time the program begins execution.

Ques: 71 What are Register Storage Classes?

Ans:

The register storage class in C++ is basically a type of auto variable, a suggestion to the compiler to use a CPU register for performance.

Ques: 72 What is the Auto Storage Class?

Ans:

The auto storage class is basically the default. Variables are automatically created and initialized when they are defined and are destroyed at the end of the block containing their definition. They are not visible outside that block.

Ques: 73 What are C++ storage classes?

Ans:

C++ storage classes are:

  • Auto
  • Register
  • Static
  • Extern

Ques: 74 What happens when we make the call “delete this;”?

Ans:

When we call “delete this”, then two cases are generated in the code. First, if it executes in a member function for an extern, static, or automatic object, the program will probably crash as soon as the delete statement executes. There is no portable way for an object to tell that it was instantiated on the heap, so the class cannot assert that its object is properly instantiated.
Second, when an object commits suicide this way, the using program might not know about its demise. As far as the instantiating program is concerned, the object remains in scope and continues to exist even though the object did itself in. Subsequent dereferencing of the pointer can and usually does lead to disaster.

Ques: 75 What does extern “C” int func(int *, Foo) accomplish?

Ans:

One can link to code compiled by a C compiler because it will turn off “name mangling” for the function.

Ques: 76 What are the access privileges in C++? What is the default access level?

Ans:

The access privileges in C++ are:

  • private
  • public
  • protected

The default access level assigned to members of a class is private. Private members of a class are accessible only within the class and by friends of the class.
Protected members are accessible by the class itself and its sub-classes.
Public members of a class can be accessed by anyone.

Ques: 77 What is the type of conversion operator?

Ans:

Conversion operators are basically of two types:

  • Implicit Conversion – These operators do not require a type cast to be specified in the source code to perform the conversion.
  • Explicit Conversion – These operators require a type cast to be present in the source code to perform the conversion.

Ques: 78 What is a conversion operator?

Ans:

Conversion operators are basically a method. They convert an object from one type to another type. A class can have a public method for specific data type conversions.

Ques: 79 What is a conversion constructor?

Ans:

A conversion constructor is basically related to typecasting of user-defined data types, i.e., conversion of one class object to another class object. A constructor with a single argument makes that constructor a conversion constructor, and it can be used for type conversion.

Ques: 80 When are copy constructors called?

Ans:

There are many important places where a copy constructor is called.

  • When an object is created from another object of the same type.
  • When an object is passed by value as a parameter to a function.
  • When an object is returned from a function.
  • When a function returns an object of that class by value.
  • When the object of that class is passed by value as an argument to a function.
  • When we construct an object based on another object of the same class.
  • When the compiler generates a temporary object.

Ques: 81 What is a copy constructor?

Ans:

A copy constructor is defined as:

  • A constructor function with the same name as the class
  • Used to make a deep copy of objects
  • Initializes object member variables with another object of the same class
  • A new object from an existing one by initialization

Ques: 82 What is the difference between const char *myPointer and char *const myPointer?

Ans:

Differences are there:
Const char *myPointer is a non-constant pointer to constant data, but in the case of char *const myPointer, it is a constant pointer to non-constant data.

Ques: 83 List out some of the OODBMS available.

Ans:

The list is there:

  • GEMSTONE/OPAL of Gemstone systems
  • ONTOS of Ontos
  • Objectivity of Objectivity Inc
  • Versant of Versant object technology
  • Object store of Object Design
  • ARDENT of ARDENT software
  • POET of POET software

Ques: 84 Give me any two main roles of the Operating System.

Ans:

The main roles are there:

  • As a resource manager
  • As a virtual machine

Ques: 85 What is the ‘*’ operator called as?

Ans:

The ‘*’ operator is used for deference, that’s why we can call it a deference operator or indirection operator.

Ques: 86 How are prefix and postfix versions of operator++() differentiated?

Ans:

In the operator ++(), the postfix version has a dummy parameter, but in the case of the prefix version, it doesn’t have one.

Ques: 87 What is containership?

Ans:

Containership is basically a type of hierarchy. It can also be called a containment hierarchy. In C++, possessing objects of other classes in a class is called containership or nesting.

Ques: 88 What is overriding?

Ans:

Overriding is basically providing a declaration which matches another declaration of the same name, thereby hiding the existing declaration. And it’s the ability to change the definition of an inherited method or attribute in the derived class.

Ques: 89 What are pointer variables?

Ans:

Pointer variables are basically variables which hold memory addresses. That variable is called a pointer variable.

Ques: 90 What are pointer constants?

Ans:

Pointer constants are basically a term in memory addresses in a computer which cannot be changed.

Ques: 91 What is runtime polymorphism?

Ans:

Runtime polymorphism is basically called the binding of an object to the corresponding function at runtime. It’s a method overriding. It takes place at runtime and looks particular to the object type.

Ques: 92 What are C-

strings or C-style strings?

Ans:
C-style strings are bassially a type of arrays of chars with a little bit of special sauce to indicate where the string ends. And in these type of arrays are also string literals, such as "this". In reality, both of these string types are merely just collections of characters sitting next to each other in memory. and its mainly use for The null terminated character arrays used to store and manipulate strings .
Ques: 93 What are abstract base classes?
Ans:
Abstract Base Classes are classes which cannot be used to create any objects.
Ques: 94 
What are �do-nothing� functions?
Ans:
�Do-nothing� functions bassicaly type of ones a function which are just defined but are not used.
Ques: 95 What is callback function?
Ans:
Callback function is the type of pointer for a function.
Ques: 96 What is a stream? and define the types of Stream?
Ans:
Its a type of interface b/w the program and the input/output devices is called a stream. Types of Streams : Input Stream : The source stream which sends data to the program is called input stream. Output Stream : The destination stream which receives output from the program is called output stream.
Ques: 97 What are stream classes?
Ans:
Strem classes are bassicaly a hierarchy of classes which are used to deal with console and disk files using different streams are called stream classes.
Ques: 98 
What is the limitation of �cin�?
Ans:
it cannot read multiple words.
Ques: 99 
What are the parts of a file name?
Ans:
A file name includes a primary name and an optional period with an extension.
Ques: 100 
What are the ways of opening a file?
Ans:
many ways are there for open the file : > A file can be opened using the constructor function of the class . and > using the member function open () of the class.


Ques: 101 What is the use of template classes and functions?
Ans:
Template classes and functions are usually use for eliminate redundancy or ambiguity of code and help in easier program or user friendly programe development.
Ques: 102 
What is the use of using?
Ans:
Using is bassically a namespace scope. Its directive used to declare the accessibility of identifiers declared within a namespace scope.
Ques: 103 What is the use of exception handling?
Ans:
Exception handling is bassically used to detect exceptions becouse it can be taken a corresponding action.
Ques: 104 
What is a file?
Ans:
A file is bassically a collection of related data. Which is store on a disk.
Ques: 105 What are manipulators?
Ans:
Manipulators bassically a type of functions. That are included in the I/O statements to alter the parameters of a stream are called manipulators.
Ques: 106 
What is EOF?
Ans:
EOF bassically stands for End of File, It is used to check for the end of file when a file is being read.
Ques: 107 What are storage qualifiers in C++ ?
Ans:
In C++ storage qualifier bassically a type of : const volatile mutable Const keyword indicates that memory once initialized, should not be altered by a program. volatile keyword indicates that the value in the memory location can be altered even though nothing in the program code modifies the contents.
Ques: 108 Give examples for synchronous exceptions?
Ans:
Syncronous Eceptions examples are there : > Out of range index > division by zero > overflow etc.
Ques: 109 In which class is the function eof () present?
Ans:
class ios.
Ques: 110 What is the difference between ios::ate and ios::app mode?
Ans:
diff are there : > Mode is that ios::ate mode allows us to add data or change data anywhere in the file But In ios::app mode allows us to add data only to the end of file.
Ques: 111 What does the file mode parameter ios::binary mean?
Ans:
It is the bassically means the file to be opened is a binary file.
Ques: 112 What are the types of file pointers?nad whats the use?
Ans:
Two types of the File Pointers : > Input pointer : The input pointer is used to read the contents in a particular file location. and > Output pointer : The output pointer is used to write the contents in a particular file location.
Ques: 113 What is the use of file pointers?
Ans:
File pointers are bassically use for moving the files and docs.Its used to move in the file while writing or reading.
Ques: 114 whats the use of seekp() and seekg()?
Ans:
they are using bassicaly move the I/O in speciafic positions : > Seekp () is used to move output/put pointer to a specified position. > seekg () is used to move input/get pointer to specified position.
Ques: 115 What is the use of tellg ()?
Ans:
tellg () provides a information about the current position of input/get pointer.
Ques: 116 What is the use of tellp ()?
Ans:
tellp ()use for the poitner postion : > Its provides the current position of output/put pointer.
Ques: 117 What are the functions used to handle single character at a time?
Ans:
they have a two functions whihc used to handle single charecter at a time : > put () and > get ()
Ques: 118 What is function overloading and operator overloading?
Ans:
Diff are there: Function overloading: C++ defines a same name of the fuctions are in diff set of paprameters.as long as the type is concerned. This capability is called function overloading. When an overloaded function is called, the C++ compiler selects the proper function by examining the number, types and order of the arguments in the call. Function overloading is commonly used to create several functions of the same name that perform similar tasks but on different data types. Operator overloading : Operator Overloading works on objects of user defned classes becouseits alows existing C++ operators to be redefined .Overloaded operators are syntactic sugar for equivalent function calls. They form a pleasant facade that doesn't add anything fundamental to the language.
Ques: 119 Define the parameterized macros?
Ans:
Parameterized macros are use for the parameters . It is the one which consist of template with insertion points for the addition of parameters.
Ques: 120 Define the generic programming?
Ans:
Generic Programmng is type of method. The method in which generic types are used as arguments in algorithms for different data types and data structures is called generic programming.


Ques: 121 
What is Memory alignment??
Ans:
The Word alignment basscially means the tendency of an address pointer value to be a multiple of some power of two. That's why a pointer with two byte alignment has a zero in the least significant bit. And a pointer with four byte alignment has a zero in both the two least significant bits and all .
Ques: 122 What is overflow error?
Ans:
Overflow error bassically a type of arithmatic errors.It's caused by the result of an arithmetic operation being greater than the actual space provided by the system.
Ques: 123 What is the use of export?
Ans:
Export is bassicaly used to instantiate the non inline template classes and its used also in functions from different files.
Ques: 124 Give an example for asynchronous exceptions?
Ans:
Asynchronous exceptions example is Keyboard interrupt.
Ques: 125 What are the basic segments of error handling code?
Ans:
Error handling is a bassicaly broad category that includes responding to many kinds of errors that are thrown during compilation or at run time. Errors that happen at compile time are often easier to identify.Its code consists of two segments one for detecting and throwing exception and the other for catching the exception.
Ques: 126 What is the use of application wizard?
Ans:
Application Wizard provides many things .Its use for ......... > quick access to your applications, documents and pictures. > Open favorite applications and groups of applications. > Quickly open recent applications. > Force applications to open using Rosetta or in Classic. > Open applications automatically at startup. > Quit multiple or all applications at one time. > Quit background-only applications and the Finder. > Force applications to quit or relaunch them. > Switch between applications. > Bring specific windows to the front when making applications active. > Show and hide groups of applications. > Turn on single application mode. > frame work for creating initial applications.
Ques: 127 Write the different forms of throw?
Ans:
the different forms of throw are there : throw (exception); throw exception; throw;
Ques: 128 
What is mean of translation?
Ans:
Translation is thebasically interpreting of the meaning of a text and the subsequent production of an equivalent text, That's called a "translation," that communicates the same message in another language. It is a creation of a new program in an alternate language which is logically equivalent the source language program.
Ques: 129 	

Give the name some pure object oriented languages. 
Ans:
Names are there: > Smalltalk > Java > Eiffel > Sather.
Ques: 130 What is the use of try block?
Ans:
Try block is the bassically used to generate exceptions.The try block is a series of statements beginning with the keyword Try, followed by an exception type and an action to be taken.
Ques: 131 
How can you catch all the exceptions without specifying individually?
Ans:
All the exceptions can be caught without specifying them individually by using ellipsis with catch. Syntax is there: catch (�) { ��� ��� }
Ques: 132 
 What is an orthogonal base class?
Ans:
Its a normally a base class if two base classes have a no overlapping properties methods they are said to be orthogonal to each other. A class can be derived from these two base classes with no difficulty.
Ques: 133 
What is the use of Microsoft foundation class library?
Ans:
The Microsoft Foundation Class Library also called as A Microsoft Foundation Classes or MFC. It is bassically a library that wraps portions of the Windows API in C++ classes,and including functionality that enables them to use a default application framework. Classes are defined for many of the handle-managed Windows objects and also for predefined windows and common controls. MFC library would help us reduce the code and development time.
Ques: 134 
What is the use of class wizard?
Ans:
class wizard bassically use for help in develope a MFC applications, Its help also in customizing the classes.
Ques: 135 
What is inline function??
Ans:
The inline keyword bassically tells the compiler to substitute the code within the function definition for every instance of a function call. Whenever, substitution occurs only at the compiler's discretion. For example, the compiler does not inline a function if its address is taken or if it is too large to inline.
Ques: 136 
Whit is the mean of precondition and post-condition to a member function.
Ans:
Precondition is defined as a condition that must be true on entry to a member function. If preconditions are never false it means class is used correctly . An operation is not responsible for doing anything sensible if its precondition fails to hold. For example, the interface invariants of stack class say nothing about pushing yet another element on a stack that is already full. We say that isful() is a precondition of the push operation. Post-condition is defines as a condition that must be true on exit from a member function if the precondition was valid on entry to that function. A class is implemented correctly when post-conditions are never false. For example, after pushing an element on the stack, we know that isempty() must necessarily hold. This is a post-condition of the push operation.
Ques: 137 What is multiple inheritance(virtual inheritance)? What are its advantages and disadvantages?
Ans:
Multiple Inheritance is bassically a process , The process when a child can be derived from more than one parent class. The advantage of multiple inheritance is that it allows a class to inherit the functionality of more than one base class thus Its allowing for modeling of complex relationships. and The disadvantage of multiple inheritance is that it can handle to a lot of confusions like ambiguities and all .... when two base classes implement a method with the same name.
Ques: 138 What is a nested class? Why can it be useful?
Ans:
Nested classes bassically useful for organizing code and controlling access and dependencies. Nested classes obey access rules just like other parts of a class do.and that class is a class enclosed within the scope of another class.
Ques: 139 
What is an Iterator class?
Ans:
this class is used for traversing. Its traverse through the objects maintained by a container class. Its have a five categories of iterators: > input iterators > output iterators > forward iterators > bidirectional iterators > random access
Ques: 140 What is an incomplete type?
Ans:
Incomplete types : > refers to pointers in which there is non availability of the implementation of the referenced location or it points to some location whose value is not available for modification.


Ques: 141 
What is a dangling pointer?
Ans:
Dangling pointer occurs when we try to use the address of an object after its lift time is finished. This may occur in situations like returning addresses of the automatic variables from a function or using the address of the memory block after it is freed.
Ques: 142 Differentiate between the message and method.
Ans:
Messages difines : > Objects communicate by sending messages to each other. > A message is sent to invoke a method. Method desines : > Provides response to a message. > It is an implementation of an operation.
Ques: 143 What is class invariant?
Ans:
A class invariant is a bassicaly type of condiation .Its defines all valid states of an object. It ensures the proper working of class.
Ques: 144 What is stack unwinding?
Ans:
Stack unwinding is a type of a process. In this process like When an exception is thrown and control passes from a try block to a handler, the C++ run time calls destructors for all automatic objects constructed since the beginning of the try block. This process is called stack unwinding.
Ques: 145 What is a node class?
Ans:
A node class defines as : > it relies on the base class for services and implementation. > It provides a wider interface to the users than its base class. > It relies primarily on virtual functions in its public interface. > It depends on all its direct and indirect base class. > It can be understood only in the context of the base class. > It can be used as base for further derivation. > It can be used to create objects. A node class is a class that has added new services or functionality beyond the services inherited from its base class.
Ques: 146 What are proxy objects?
Ans:
Proxy object is a bassically that type of object which Objects that stand for other objects are called proxy objects or surrogates.
Ques: 147 Define namespace.
Ans:
Namespaces is a bassically feature of C++. it is a relatively new C++ feature just now starting to appear in C++ compilers. We will be describing some aspects of namespaces in subsequent newsletters.
Ques: 148 
What is an iterator class?
Ans:
An iterator class is bassically use for traversing. that are traverse through the objects maintained by a container class.
Ques: 149 
When does a name clash occur?
Ans:
when we use a same name for all the classes
Ans:
when we use a same name for all the classes
Ans:
When we dont use "using namespace std;"
Ques: 150 What are the types of container classes? 
Ans:
A container class bassically that class whihc is used to hold objects in memory or external storage. this class acts as a generic holder. It has a predefined behavior and a well-known interface. Its a type supporting class which mainly purpose is to hide the topology used for maintaining the list of objects in memory. When a container class contains a group of mixed objects, that tyme its called heterogeneous container; when the container is holding a group of objects that are all the same, that tyme its called homogeneous container.
Ques: 151 give me a diff b/e Template class and class Template?
Ans:
Many diff are there : Template Class bassically a parameterized class not instantiated until the client provides the needed information. It�s jargon for plain templates. But in the Class template specifies how individual classes can be constructed much like the way a class specifies how individual objects can be constructed. It�s jargon for plain classes.
Ques: 152 wat do you mean by accessor?
Ans:
it is type of class operation, its does not modyfying the state of an object, these type of fuctions needs to be declare as a constant operation.
Ques: 153 What is a modifier?
Ans:
A modifier as a modifying function is a member function which changes the value of at least one data member. In other words, we can say an operation that modifies the stateof an object. Modifiers are also known as �mutators�.
Ques: 154  Explain the scope resolution operator?
Ans:
scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope.
Ques: 155 What are the access privileges in C++?
Ans:
C++ has three access privileges. They are private, public and protected. public- inherite the protected members as preotected in drived class and pubic members will be public in derived class. protected- pubic and protecated members of the base class will become protected in derived class Private- pubilc and proteacted members will become private in derived class.
Ques: 156 What is the mean of Manglic in C++?
Ans:
Mangling is difine as : > A C++ compiler generates function names that include an encoding of the function's argument types. This is known as name mangling. There is no general standard for name mangling. Although all C++ compilers incorporate name mangling, no two do it the same way. We can avoid name mangling by declaring the functions as extern "C"; but we can do this for only one of a set of functions with the same name .
Ques: 157 What is 'this' pointer?
Ans:
'this' pointer is a hidden member of a class or struct.it is bassicaly hidden parameter of non-static member functions. It is a pointer accessible only within the member functions of a class, structure, or union type.
Ques: 158 
Declare a void pointer. 
Ans:
void pointer bassicaly used to store address of any type of variable. This is very useful when we want a pointer to point to data of different types at different times.
Ques: 159 How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters? 
Ans:
We have a three ways for declaring techniques : 1. char *(*(*a[P])())(); 2. Build the declaration up in stages, using typedefs: typedef char *pc; /* pointer to char */ typedef pc fpc(); /* return function pointer to char */ typedef fpc *pfpc; /* pointer to above */ typedef pfpc fpfpc(); /* returning function */ typedef fpfpc *pfpfpc; /* pointer to*/ pfpfpc a[P]; /* array of*/ 3. Use the cdecl program, which turns English into C and vice versa: cdecl> declare a as array of pointer to function returning pointer to function returning pointer to char char *(*(*x[])())()
Ques: 160 What does extern mean in a function declaration? 
Ans:
Extern is bassically significant only with data declarations. In the function declaration case, It can be used as a stylistic hint to indicate that the function's definition is probably in another source file, but there is no formal difference between extern int A(); and int A();
Ques: 161 What�s the best way to declare and define global variables? 
Ans:
Best Way to represent a variable as global is - Just define the variable at the initial or just below the headers files. though there can be many "declarations" of a single "global" variable or function, there must be exactly one "definition". If a program is in several source files,the best arrangement is to place each definition in some relevant source file, with an external declaration of function n variables in a seperate header file that is included by #include at the front of each source file.
Ques: 162 How do you decide which integer type to use? 
Ans:
It depends on data which programmer want to use, it ups to the implementor to decide what it means to be a fast integer type.
Ques: 163 Is there anything you can do in C++ that you cannot do in C?
Ans:
No. There is nothing you can do in C++ that you cannot do in C. After all you can write a C++ compiler in C
Ques: 164 Why do C++ compilers need name mangling?
Ans:
Name mangling is the rule according to which C++ changes function's name into function signature before passing that function to a linker. This is how the linker differentiates between different functions with the same name.
Ques: 165 What issue do auto_ptr objects address?
Ans:
If you use auto_ptr objects you would not have to be concerned with heap objects not being deleted even if the exception is thrown. Q33:Is there any problem with the following: char *a=NULL; char& p = *a;? The result is undefined. You should never do this. A reference must always refer to some object.
Ques: 166 Can you think of a situation where your program would crash without reaching the breakball, which you set at the beginning of main()?
Ans:
C++ allows for dynamic initialization of global variables before main() is invoked. It is possible that initialization of global will invoke some function. If this function crashes the crash will occur before main() is entered.
Ques: 167 What happens when a function throws an exception that was not specified by an exception specification for this function?
Ans:
Unexpected() is called, which, by default, will eventually trigger abort().
Ques: 168 What is the difference between new/delete and malloc/free?
Ans:
Malloc/free do not know about constructors and destructors. New and delete create and destroy objects, while malloc and free allocate and deallocate memory.
Ques: 169 How do you know that your class needs a virtual destructor?
Ans:
If your class has at least one virtual function, you should make a destructor for this class virtual. This will allow you to delete a dynamic object through a baller to a base class object. If the destructor is non-virtual, then wrong destructor will be invoked during deletion of the dynamic object.
Ques: 170 
When is a template a better solution than a base class?
Ans:
When you are designing a generic class to contain or otherwise manage objects of other types, when the format and behavior of those other types are unimportant to their containment or management, and particularly when those other types are unknown (thus, the generality) to the designer of the container or manager class.
Ques: 171 Explain the ISA and HASA class relationships. How would you implement each in a class design?
Ans:
A specialized class "is" a specialization of another class and, therefore, has the ISA relationship with the other class. This relationship is best implemented by embedding an object of the Salary class in the Employee class
Ques: 172 How the compilers arranges the various sections in the executable image?
Ans:
The executable had following sections:- Data Section (uninitialized data variable section, initialized data variable section ) Code Section Remember that all static variables are allocated in the initialized variable section.
Ques: 173 What are the debugging methods you use when came across a problem?
Ans:
Debugging with tools like : GDB, DBG, Forte, Visual Studio. Analyzing the Core dump. Using tusc to trace the last system call before crash. Putting Debug statements in the program source code.
Ques: 174 n a constructor throw a exception? How to handle the error when the constructor fails?
Ans:
The constructor never throws a error.
Ques: 175 What is a virtual destructor?
Ans:
The simple answer is that a virtual destructor is one that is declared with the virtual attribute. The behavior of a virtual destructor is what is important. If you destroy an object through a baler or reference to a base class, and the base-class destructor is not virtual, the derived-class destructors are not executed, and the destruction might not be compile.
Ques: 176 When should you use multiple inheritance?
Ans:
There are three acceptable answers:- "Never," "Rarely," and "When the problem domain cannot be accurately modeled any other way." Consider an Asset class, Building class, Vehicle class, and CompanyCar class. All company cars are vehicles. Some company cars are assets because the organizations own them. Others might be leased. Not all assets are vehicles. Money accounts are assets. Real estate holdings are assets. Some real estate holdings are buildings. Not all buildings are assets. Ad infinitum. When you diagram these relationships, it becomes apparent that multiple inheritance is a likely and intuitive way to model this common problem domain. The applicant should understand, however, that multiple inheritance, like a chainsaw, is a useful tool that has its perils, needs respect, and is best avoided except when nothing else will do.
Ques: 177 What is the difference between a copy constructor and an overloaded assignment operator?
Ans:
A copy constructor constructs a new object by using the content of the argument object. An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class.
Ques: 178 How many ways are there to initialize an int with a constant?
Ans:
1. int f = 123; 2. int bar(123);
Ques: 179 Explain the scope resolution operator?
Ans:
It permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope.
Ques: 180 
How do you link a C++ program to C functions?
Ans:
By using the extern "C" linkage specification around the C function declarations. Programmers should know about mangled function names and type-safe linkages. Then they should explain how the extern "C" linkage specification statement turns that feature off during compilation so that the linker properly links function calls to C functions.
Ques: 181 Can inline functions have a recursion?
Ans:
No. Syntax wise It is allowed. But then the function is no longer Inline. As the compiler will never know how deep the recursion is at compilation time.
Ques: 182 How Virtual functions call up is maintained?
Ans:
Through Look up tables added by the compile to every class image. This also leads to performance penalty.
Ques: 183 What is problem with Runtime type identification?
Ans:
The run time type identification comes at a cost of performance penalty. Compiler maintains the class.
Ques: 184 What about Virtual Destructor?
Ans:
Yes there is a Virtual Destructor. A destructor can be virtual as it is possible as at runtime depending on the type of object baller is balling to , proper destructor will be called.
Ques: 185 Is it possible to have Virtual Constructor? If yes, how? If not, Why not possible ?
Ans:
There is nothing like Virtual Constructor. The Constructor cant be virtual as the constructor is a code which is responsible for creating a instance of a class and it cant be delegated to any other object by virtual keyword means.
Ques: 186 How do I write code that reads data at memory location specified by segment and offset? 
Ans:
Use peekb( ) function. This function returns byte(s) read from specific segment and offset locations in memory. The following program illustrates use of this function. In this program from VDU memory we have read characters and its attributes of the first row. The information stored in file is then further read and displayed using peek( ) function. #include #include main( ){ char far *scr = 0xB8000000 ; FILE *fp ; int offset ; char ch ; if ( ( fp = fopen ( "scr.dat", "wb" ) ) == NULL ) { printf ( "\nUnable to open file" ) ; exit( ) ; } for ( offset = 0 ; offset
Ques: 187 How do I know how many elements an array can hold?
Ans:
main( ){ int i[32767] ; float f[16383] ; char s[65535] ; }
Ques: 188 
Why doesn't the following statement work?
char str[ ] = "Hello" ;
strcat ( str, '!' ) 
Ans:
The string function strcat( ) concatenates strings and not a character. The basic difference between a string and a character is that a string is a collection of characters, represented by an array of characters whereas a character is a single character. To make the above statement work writes the statement as shown below: strcat ( str, "!" ) ;
Ques: 189 Why doesn't the following code give the desired result?
Ans:
:int x = 3000, y = 2000 ; long int z = x * y ; Ans:Here the multiplication is carried out between two ints x and y, and the result that would overflow would be truncated before being assigned to the variable z of type long int. However, to get the correct output, we should use an explicit cast to force long arithmetic as shown below: long int z = ( long int ) x * y ; Note that ( long int )( x * y ) would not give the desired effect.
Ques: 190 
What will be the output of the following code?
void main (){
 int i = 0 , a[3] ;
a[i] = i++;
printf ("%d",a[i]) ;
} 
Ans:
The output for the above code would be a garbage value. In the statement a[i] = i++; the value of the variable i would get assigned first to a[i] i.e. a[0] and then the value of i would get incremented by 1. Since a[i] i.e. a[1] has not been initialized, a[i] will have a garbage value.
Ques: 191 What is Difference Between C/C++
Ans:
In C passing value to a function is "Call by Value" whereas in C++ its "Call by Reference" 2.C does not have a class/object concept. C++ provides data abstraction, data encapsulation, Inheritance and Polymorphism. 3.C++ supports all C syntax. File extension is .c in C while .cpp in C++.(C++ compiler compiles the files with .c extension but C compiler can not!) 4.In C structures can not have contain functions declarations. In C++ structures are like classes, so declaring functions is legal and allowed. C++ can have inline/virtual functions for the classes. c++ is C with Classes hence C++ while in c the closest u can get to an User defined data type is struct and union.
Ques: 192 
What is the difference between run time binding and compile time binding?
Ans:
Dynamic Binding:This is also known as "Late Binding".The address of the functions are determined at runtime rather than at compile time. Static Binding:This is also known as "Early Binding" .The address of the functions are determined at compile time rather than at run time.
Ques: 193 
What is Operator overloading?
Ans:
When an operator is overloaded, it takes on an additional meaning relative to a certain class. But it can still retain all of its old meanings. Examples: 1) The operators >> and
Ques: 194 What is Smart Pointer?
Ans:
Its a bassicallly a objects which is store pointers to dynamically allocated objects. These pointers are seen as owning the object pointed to, And thus responsible for deletion of the object when it is no longer needed.smart pointer is an abstract data type that simulates a pointer while providing additional features.
Ques: 195 
What is the difference between a pointer and a reference?
Ans:
diff are there : >References are aliases to variables , or we can say other name to a given variable, Even pointer holds the address of a particular variable. > A Reference can be thought of as a special type of pointer with certain restrictions. > We can create the array of Pointer but its not in case of reference. > We can use pointer to pointer but we cnt us reference to referece. > We can assign NULL to the pointer but in refencer we can't. > References have to be initialised at the time of declaration and cannot be changed in the code later , whereas this does'nt hold true with the pointer.
Ques: 196 
What is importance of const. pointer in copy constructor?
Ans:
Importance of copy constructor : > Copy constructor is useful when an object is initialized with another existing object or an object is passed by value to a function or an object is returned by value from a function.
Ques: 197 What is a fake pointer?
Ans:
it is used to creat a illusion or vertual functianality of pointer,which is used to mutate the objects where single objects have multiple functionality at same time.
Ques: 198 What is the diffrence between static_cast and dynamic_cast in RTTI
Ans:
Static_cast from a base class pointer to a derived class pointer. It will do this properly for the up cast, And also properly for the downcast, If the object is actually a derived class. If the object wasn't, we'ld get a pointer as if it were, but this might be very bad. > RTTI is not an option and It is an embedded product. Therefore dynamic_cast is not an option.
Ques: 199 
What do you mean by pure virtual functions?  
Ans:
A pure virtual function is a bassically which function that must be overridden in a derived class and need not be defined. A pure virtual member function is a member function that the base class forces derived classes to provide. Any class containing any pure virtual function cannot be used to create object of its own type.
Ques: 200 
What is virtual class and friend class?
Ans:
friend class is the bassically which class used when two or more classes are designed to work together.used to share private data between 2 or more classes the function declared as freind are not called using any object it is called like normal . But in virtual class is whihc class aids in multiple inheritance, it is used for run time polymorphism when object is linked to procedure call at run time.


Ques: 201 
What is public, protected, private?
Ans:
Public variables - that are visible to all classes. Private variables - that are visible only to the class to which they belong. Protected variables - that are visible only to the class to which they belong, and any subclasses.
Ques: 202 
What are Polymorphic Classes?
Ans:
polymorphic class declares or inherits a virtual function. A template class is nothing but a polymorphic class is - because it can work with different data-types, also under one name.
Ques: 203 
Explain why encapsulation is required?
Ans:
Encapsulation bassically defined as : > Encapsulation genral meaning is information hiding. > The purpose of efficiency of memory and speed. > The data and code binds together. > It is an OOP principle of placing the data and functionality within a single entity. > it is to protect data from the client using the classes but still allowing the client to access the data, but not modify it.
Ques: 204 
What are the disadvantages of C++?
Ans:
Disadvantages: > It's not pure object oriented programming language. > Its a Platform dependent > C++ does not give excellant graphics as compare to java. > Its Not case sensitive. > C++ have Less features as comapred to Java& C#. > Its Not applicable in web enviornment. > Does not provide very strong type-checking. > c++ code is easily prone to errors related to data types, their conversions. > Does not provide efficient means for garbage collection. > No built in support for threads.
Ques: 205 
While copying the objects if we say X a=b, X a(b) What will it call, assignment operator or copy constructor? Justify
Ans:
class check { public: int a,b; check (); check(const check&); check operator=(const check&); virtual ~check(); }; check::check(const check& y) { cout ;>;>
Ques: 206 
What is the difference between char str, char *str and char* str ?Explain the meaning of char* or int* ?
Ans:
Char *str is just a pointer its can't store anything, If we cout or printf() char *str it prints till it finds termination char ''; char str is a char variable which is capable to store one character and store a string also. Its length can be fixed only at run time.Char* is pointer which store address of char variable .
Ques: 207 
What are anonymous structure, unions and what are their uses?
Ans:
Anonymous unions are standard C++, and they can be found inside an object or inside a namespace. But Anonymous structures are not standard C++, therefore they are implemented as extensions.
Ques: 208 Why the size of empty Class is one byte?
Ans:
Everything must have a diff address in memory, otherwise there are very confusion with pointers. Hence even an empty class takes up one byte so the next thing we declare will have a different address.
Ques: 209 
What is structure padding.Describe briefly?
Ans:
structure padding use for avoid the problems , We can use __attribute__(( xxxx )).Structure padding occurs because the structure members must appear at the correect byte boundary, to achieve this the compiler puts in padding bytes so that the structure members appear in the correct location.
Ques: 210 
Why an empty Structure will occupy 2Bytes in C++
Ans:
Structure name assign a 1 byte from compiler side, spo Size of empty structure in C++ is 1 byte, Classes have no member that's why objects have 0 bytes, However the objects must be legally creatable because the class is not abstract so there must be a way to address the objects.
Ques: 211 What is the compilation difference at the compiler level for C++, VC++ and C# ?
Ans:
The C++ compiler has the ability to produce both native and managed instructions.and VC++ is the Microsoft's implementation of C++. Each C++ compiler might compile the code differently but in C# ompiles first into CIL (Common Intermediate Language) and then on runtime.
Ques: 212 
What is operator overloading?what r the advantages of operator overloading?
Ans:
operator overloading is the property of Object oriented programming which gives an extra ability to an operator to act on a User-defined operand(Objects). Advantages: > It will act differently depending on the operands provided. Its called extesibility. > It is not limited to work only with primitive Data Type. > By using this overloading we can easily acces the objects to perform any operations. > It makes code much more readable.
Ques: 213 
Difference between a "assignment operator" and a "copy constructor"
Ans:
many diff are there : > Copy constructor copies a existing object to a non existing object, which we are going to create. Assignment operator can happen between two existing objects. > copy constructor creates shallow copy assignment operator creates deep copy. > Assignment operator assign the value of one object to another aftr the 1st object is fully created but in copy constructor it assign the value of one object to another at the time of its creation. > Copy constructor donot return anything. Assignment operator returns object of same type. > Copy constuctor initialize the object with the another object of same class whereas assignment operator can be called on objects of different classes .
Ques: 214 
What is namespace?
Ans:
Namespaces bassically provide a simple method for qualifying element and attribute names used in Extensible Markup Language documents by associating them with namespaces identified by URI references. Its allow to group entities like classes, objects and functions under a name. This way the global scope can be divided in "sub-scopes", each one with its own name. It is an abstract container providing context for the items. it holds and allowing disambiguation of items having the same name.
Ques: 215 
What is a scope resolution operator?
Ans:
Scope Resolution Operator is defined as (::). It used to define the member functions of a class outside the class. It shows the scope resolution operator untangling a mess made by using the same names for different kinds of entities. it resolves global scope to local scope. Ex: int x=20; int main() { x=30; cout;>;>;>
Ques: 216 What is the use of new operator?
Ans:
In C++ New Operator used to allocate the memory for the object on HEAP. It allocates the memory of size equal to the object of size, The new operator will return NULL or throw an exception on failure. It provides dynamic storage allocation. Its syntax for an allocation expression containing the new operator is: >>-+----+--new--+---------------------+--+-(--type--)-+---------> '-::-' '-(--argument_list--)-' '-new_type---' >--+-------------------------+--------------------------------->
Ques: 217 
What was the most difficult debug you have ever done?
Ans:
whenever any application get hanged, & we don't know even from wherewe should start debuging....this can be the most difficult .
Ques: 218 How will you detect if there is memory leak in your C++ program?
Ans:
Some time before we have got a some problem of detecting memory leaks in our code, and we didn't afforrd the rates of a brittle software package to do that. It's fairly simple to redefine malloc() and free() to your own functions, to track the file and line number of memory leaks. But what about the new() and delete() operators? It's a little more difficult with C++, if we want to figure out the exact line number of a resource leak. If we are using new and delete operator, We can overload both the operators and can count number off heap allocation and deallocation. You can also get the __FILE__ and __LINE__ to get to know the file name and line number. Now the new and delete of a memory location should be in pair and if its not there is a memroy leak. By using line and file utility you can reach upto the exact location.
Ques: 219 What is the difference between block structured language and highly block structured language
Ans:
Block Structure Langguage Bassically a normal programming language in which sections of source code contained within pairs of matching delimiters such as "" and "" (e.g. in C) or "begin" and "end" (e.g. Algol) are executed as a single unit. Its A class of high-level languages in which a program is made up of blocks � which may include nested blocks as components, such nesting being repeated to any depth.
Ques: 220 
What happens to the member function in the class when copy constructor is invoked?
Ans:
First of all we want to tell you that only the member function have the athourity to invoke any other member function.But cunstructor have a diff property, is that it used to initialise the values to data members. and they are constant and it cannot be invoked any other constuctor. If they are copied compiler should not understand or didnot diffrentiate that what is member function and what is constructor, so ambiquity will be raised.
Ques: 221 
What is RTTI?
Ans:
RTTI bassicaly Run Time Type Information. It Certain language features to work a limited amount of information about types is required at runtime. This is the Run Time Type Information or RTTI.
Ques: 222 
What are virtual functions?  
Ans:
virtual functionsdefines as : > C++ virtual function is a member function of a class, whose functionality can be over-ridden in its derived classes. The whole function body can be replaced with a new set of implementation in the derived class. > A virtual function is a member function which we may redefine for other derived classes, And can ensure that the compiler will call the redefined virtual function for an object of the corresponding derived class, Even if we call that function with a pointer or reference to a base class of the object. > A virtual function is a member function of a class, which functionality can be over-ridden in its derived classes. It is one that is declared as virtual in the base class using the virtual keyword. > C++ virtual function properties are: * A member function of a class. * Declared with virtual keyword. * Usually has a different functionality in the derived class. * A function call is resolved at run-time.
Ques: 223 
What is the difference between far pointer and near pointer?
Ans:
Many diff are there : > A normal pointer can only point to the main memory location, But the far pointer can have an address of any location of ur memory even seconday one also. > A far pointer is used to access a location which is outside current segment. > Near pointers are fully recognised and evaluated for their entire width. But in Far pointers only allow normal operations to be done to their offset amount and not the segment or paragraph amount.
Ques: 224 What is difference between visual c++ & ANSI c++ ?
Ans:
Visual C++ is probably the most popular favored compiler, because of it's history of quality and stablity.But in ANSI C++ is a less popular, but is a much more powerful and robust compiler. The IDE is also a lot more powerful than MSVC.
Ques: 225 What is the advantage of function overloading according to users point of view?
Ans:
We know that function name is same. But each time we are writing code for each function. In this case it is advantageous than normal function.
Ans:
waste site
Ques: 226 Difference between a "assignment operator" and a "copy constructor"
Ans:
many diff are there : > Assignment operator assign the object of one object to another aftr the 1st object is fully created but in copy constructor it assign the value of one object to another at the time of its creation . > The copy constructor is use for initialising a new instance from an old instance, And is called when passing variables by value into functions or as return values out of functions. but in Assignment operator is used to change an existing instance to have the same values as the rvalue, which means that the instance has to be destroyed and re-initialized if it has internal dynamic memory. > Copy constructor copies a existing object to a non existing object, which we are going to create. Assignment operation can happen between two existing objects. > The copy constructor is creating a new object. But in The assignment operator has to deal with the existing data in the object. > Copy constructor creates shallow copy but in assignment operator creates deep copy. > The copy constructor is called at initialising the object but the assignment operator is used to assign one object to another. > Copy constructor donot return anything. But in Assignment operator returns object of same type. > The copy constructor initializes uninitialized memory, But in assigenment operator starts with an existing initialized objects. > Copy constuctor initialize the object with the another object of same class But assignment operator can be called on objects of different classes .
Ques: 227 What is the difference between "overloading" and "overriding"?
Ans:
Many Diffreces are there- Overloading a method (or function) in C++ is the ability for functions of the same name to be defined as long as these methods have different signatures (different set of parameters). Method overriding is the ability of the inherited class rewriting the virtual method of the base class. overridding is runtime polymorphism while overloading is compile time polymorphism.
Ques: 228 Difference between "C structure" and "C++ structure".
Ans:
Many diff are there : >Structure in C defines as limited to within the module and cannot be initialized outside but Structure in C++ can initialize the objects anywhere within the boundaries of the project. > C++ have a many methods((Procedures) but in C no methods are there. > By default C structure are Public and C++ structure are private . > C does not support Methods inside structure but C++ does. > In C++ structure we can add functions but in C structure we can't. > In C++, structure behaves like class like can add function, and can use properties on class as inheritance, virtual,etc, But in C, structure we can have only data member but not functions. > Structures in c++ doesnot provide datahiding but a class provides. > classes support polymorphism, But Structures don't.
Ques: 229 What is the difference between operator new and the new operator?
Ans:
Many diff are there : Operator new is bassically just like malloc and new is the conventinally new in C++. The "New" operator allocates a new instance of an object from the heap, Its utilising the most appropriate constructor for the arguments passed. This is Like many operators in C++, The "New" operator for a particular class can be overriden, Although there is rarely a need to do so. "Operator new" is the mechanism for overriding the default heap allocation logic.
Ans:
Operator new() use for the Operator overloading but New Operator for memory allocation.
Ques: 230 What is virtual constructors/destructors? 
Ans:
virtual constructors/destructors : Virtual destructors It is a Bassically same as vertual fuction, Its commonly used with inheritance. Since an abstract class must contain a pure virtual method that has to be overridden, a lot of developers commonly declare their destructors pure virtual, since a destructor is sure to be implemented in every subclass. Constructors cannot be virtual. Declaring a constructor as a virtual function is a syntax error. There is no virtual constructor coz virtual thing is in run time n constructor is compile time thing.
Ques: 231 What is a template?  
Ans:
Templates is defined as : > It is a framework for web pages and sites. > Its type of model or standard for making comparisons. > It is a feature of the C++ programming language its allow functions and classes to be operate with generic types. > It is a tool for enforcing a standard layout and look and feel across multiple pages or within content regions. > Its a model or pattern used for making multiple copies of a single object.
Ques: 232 Difference between realloc() and free()?  
Ans:
Diff b/w realloc() and free(): realloc(): > It is used to free the memory in the program. > This function is used to resize memory. > realloc() means it giving string variables into the existed memory free(): > Basically It is a macro. Macro used to deallocate memory. > free() function is used free the memory which is allocated by malloc(),calloc() functions. > free() means it empties the array.
Ques: 233 What is the difference between an object and a class? 
Ans:
Class and Objects are diff but related concepts. Every objects belogs to the class and evry class have a one or more related objets. Class are: > A Class is static. > A class combination of data(called data members)and functions(called member functions). > Class is a userdefined datatype with data members and member functions. > Classe defines object. > One class can define any no of Object. > Class is a template(type) or blue print its state how objects should be and behave. Object are: > Object is an instance of a class while a class can have many objects. > Object is a dynamic. > Objects are the basic runtime entities in an object oriented sysyem. > Data and function which combine into a single entity is called object. > Objects are instances of classes which identifies the class propeties. > Object can't define classes. > Object can created and destroyed as your necessity. > Object is defined as a s/w construct which binds data and logic or methods(functions) both.
Ques: 234 
What is the difference between class and structure?
Ans:
Diff b/w Class and Structure is : Class is difined as- >Class is a successor of Structure. By default all the members inside the class are private. >Class is the advanced and the secured form of structure. >Classes are refernce typed. >Class can be inherited. >In Class we can initilase the variable during the declaration. >Class can not be declared without a tag at the first time. >Class support polymorphism. Structure difine as : > In C++ extended the structure to contain functions also. All declarations inside a structure are by default public. > Structures contains only data while class bind both data and member functions. > Structure dosen't support the polymorphism, inheritance and initilization. > Structure is a collection of the different data type. > Structure is ovrloaded. > Structures are value type. > Structure can be declared without a tag at the first time
Ques: 235 Question :

what is the difference between parameter and argument?


Ans:
Diff b/w parameter and argument is : Argument bassically is one of the following - > An Expression in the comma-separated list in a function call. > A sequence of one or more preprocessor tokens in the comma-separated list in a macro call. > Its represent the value which you pass to a procedure parameter when you call the procedure. The calling code supplies the arguments when it calls the procedure. > It is something passed into a function(value), whereas a parameter is the type of data plus the name. Parameter bassically is one of the following - > An object that is declared in a function declaration or definition. > An identifier b/w the parentheses immediately following the macro name in a macro definition. > It is represent a value that the procedure expects you to pass when you call it. The procedure's declaration defines its parameters. This example explains the difference b/w a parameter and an argument: void function(int x, char * rs); //x and rs are parameters template class M {}; //Tem is a parameter int main() { char c; char *p = &c; func(5, p); //5 and p are arguments M a; //'long' is an argument M another_a; //'char' is an argument return 0; }