Your Ad Here

Sunday, December 28, 2008

Recent C++ Interview questions & Answers

Q : Explain in void pointer using C++?
A : In C++, void represents the absence of type, so void the pointers are pointers that point to a value that has no type. The void pointers can point to any data type.
We can declare void pointer as follows.
Void *p;

Q : What is the function overloading in C++?

A : You can have the multiple functions with same name using function overloading facility of C++. You can use same name for multiple functions when all these functions are doing same thing.

Q : What is virtual function?
Answer - Virtual function is the member function of a class that can be overridden in its derived class. It is declared with virtual keyword. Virtual function call is resolved at run-time (dynamic binding) whereas the non-virtual member functions are resolved at compile time (static binding).

Q : What is Null object in C++?
A : Null Object is an object of some class whose purpose is to indicate that a real object of that class does not exist. One common use for a null object is a return value from a member of function that is supposed to return an object with some specified properties but cannot find such an object.

Q : What is virtual function? where is it used?
A : Virtual function is a member of function that is declared by with in a base class and redefined by the derived class. to make a function virtual prefix the function name by the "virtual" keyword. It helps in polymorphism.

Q : what is a template
A template function defines a set of operations to performed on the various data types This data is passed to the function as an argument

Q : What do you mean by the inheritance?
A : The Inheritance is the process by which one can aquire the properties of another object

Q : Explain the scope resolution operator?
A: The scope resolution operator is a permits of 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.

Q : What is parameterized type?
A : : A template is a parameterized construct or type containing the generic code that can use or manipulate any type. It is called the parameterized because an actual type is a parameter of the code body. Polymorphism may be achieved through parameterized types. This type of polymorphism is called parameteric polymorphism. Parameteric polymorphism is the mechanism by which the same code is used on different types passed as parameters.

Q : Explain the scope resolution operator?
A :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.

Q : Name of the some pure object oriented languages?
A : Some pure object oriented languages are
• Smalltalk,
• Java,
• Eiffel,
• Sather.

Q : Differentiate between a C++ struct and C++ class?
A : The default member and base-class access specifies are different. This is one of the commonly misunderstood aspects of C++. Believe it is or not, many programmers think that a C++ struct is just like a C struct, while a C++ class has inheritance, access specifies, member functions, overloaded operators, and so on. Actually, the C++ struct has all the features of the class. The only differences are that a struct defaults to public member access and public base-class inheritance, and a class defaults to the private access specified and private base-class inheritance.

Q : Why do C++ compilers need the name mangling?
A : Name mangling is the rule of according to which is the C++ changes function's name into function signature before the passing that the function to a linker. This is how the linker differentiates between different functions with the same name.

Q : What is protocol class?
A : An abstract class is a protocol class if:
1.Protocol neither contains nor inherits from the classes that contain member data, non-virtual functions, or private (or protected) members of any kind.
2. It has a non-inline virtual destructor defined with an empty implementation,
3. All member functions other than the destructor including inherited functions, are declared pure the virtual functions and left undefined.

Q : What is the difference between the message and method?
A: Method: Provides response to a message.It is an implementation of an operation..
Message: Objects communicate by sending the messages to each other.A message is sent to invoke a method.]

Q : What is an adaptor class ?
A : A class that has no functionality of its own. It is the member functions hide the use of a third party software component or an object with the non-compatible interface or a non- object- oriented implementation.

Q : What’s the difference between char a[] = “string”; and char *p = “string”;?
A : In the first case six bytes are allocated to the variable in a which is fixed, where as in the second case if *p is assigned to the some other value the allocate memory can change.

Q : What is conversion constructor?
A : A conversion constructor is that accepts one argument of a different type.

Q : What’s an explicit constructor?
A : A conversion constructor declared with the explicit keyword. The compiler does’nt use an explicit constructor to implement an implied conversion of types. It is the purpose of is reserved explicitly for construction.

C++ Interview Questions & Answers

Q : How do youn delete an element in array of string?

A : Reduce the array size.

if(stringarryname)

{

delete[] stringarryname;

delete stringarryname;

stringarryname = NULL;

}


Q : What is the difference between an overload assignment operator and an a copy constructor?

A :. An overloaded assignment operator assigns the contents of an existing object to another existing object of the same class. A copy constructor constructs a new object by using the content of the argument object


Q :What is the virtual destructor?

A : The 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.

Q: What is the Difference between C and C ++?

A : C is a structured programming language. The C++ is an object oriented language. C++ is also called as C with Classes.

both C and C++ are programming languages. C++ is termed as superset of C.
C is a powerful and elegent language.almost all c PROGRAMS ARE ALSO c++ PROGRAMS. C, it facilitates--" topdown structured design" as against C++ provides bottom-up object-oriented design. C language is built from functions (like printf)that execute different tasks.

Q : Difference between a template class and class template in C++?

A : Template class: A generic definition or a parametrized class not instantiated until the client provides the needed information. It is the jargon for plain templates.
Class template: A class template specifies how individual classes can be constructed much like the way a class specifies how individual objects can be constructed. It is jargon for plain classes.

Q : What is the polymorphism in C++?

A : Polymorphism in the C++ is the idea that a base class can be inherited by several classes. A base class pointer can point to its child class and base class array can store different child class objects.

Recent Data Structure Interview Questions & Answers

Q : What’s the purpose of a left child node and a right child node?
A : The left child node and right child node helps in sorting technology because parent will be having larger value than that of left and left child will be having larger value than that of right.

Q : What is the advantage of using a queue linked list?
A : The Most Important is CPU Scheduling , refers a Queue for scheduling.
Queue is to Faster then Other One(stack)

Q : What is linked list?
A : Linked list is a data structure which is contain the data elements and a pointer of the node type of which points to the next node in the linked list. It is useful when you do not know in advance how many elements will be there so you cannot pre allocate space (e.g. using an array).

Q : Which data structure is used to perform the recursion?
A : Stack has the LIFO (Last In First Out) property; it remembers it is a ‘caller’. Therefore, it knows as to whom it should return when the function has to return. On the other hand, recursion makes use of the system stack for storing the return addresses of the function calls. Every recursive function has its equivalent iterative (non-recursive) function. Even when such the equivalent is iterative procedures are written explicit, stack is to be used.

Q : What are some of the applications for the tree data structure?
A : There are three types of the application for the tree data structure,
• Symbol table construction.
• Manipulation of the arithmetic expressions.
• Syntax analysis

Q : What is spanning Tree?
A : A spanning tree is a tree associated with a network. All the nodes are the graph appear on the tree once. A minimum spanning tree is a spanning tree organized so that the total edge weight between nodes is minimized.

Q : What’s the difference between STACK and ARRAY?
A : In array the items can be entered or removed in any order. Basically each member access is done using the index. No strict order is to be followed here to remove a particular element. STACK follows LIFO. Thus the item that is first entered would be the last removed.

Q : What is the method removes the value from the top of a stack?
A : The pop() member method removes the value from the top of a stack, which is then returned by the pop() member method to the statement that is called the pop() member method.

Q : What is queue ?
A : A Queue is a sequential organization of data. A queue is a FIFO type of data structure. An element is an inserted at the last position and an element is always taken out from the first position.

Q : Difference between malloc and calloc ?
A : calloc: allocate the m times n bytes initialized to 0
malloc: allocate the n bytes.

Q : what is an abstract data type?
A : Abstract data type is a logical cohesion of operands or variables along with a set of operation which can be performed on it. In Java we have most of data types as abstract data types. It helps in implementing the oops concept of encapsulation, abstraction, modularisation. Eg :String data type in java is an abstract data type. String is defined as a character array data member of a class All operations related to or which can be performed on strings are included as methods of the class.

Q : What’s the difference between bubble sort & quick sort?
A : Bubble sort is a very easy to program, slower, iterative. Compares neighboring numbers swaps it if required and continues this procedure until there are no more swaps
Quick Sort is a little difficult to program, Fastest, Recursive. Pivot number is selected, other numbers are compared with it and shifted to the right of number or left depending upon criteria again this method is applied to the left and right list generated to the pivot point number. Select pivot point among that the list.

Q : What is linear and non-linear data structures?
A : Linear data structure is an array, linked list
Non linear data structure is a tree, graph

Q : What is user-defined data type?

A : A user defined data type is a structure of which contains variables of basic data types.
For (ex) user can define a data type called employee which contains variables like string EmpName, int DeptNo, float Salary etc.

RDBMS Interview Questions & Answers

Q : What is a database?
A : A database is a logically coherent collection of data with the some inherent meaning, representing some aspect of real world and which is designed, built and populated with the data for a specific purpose.

Q : What is Data Independence?
A : Data independence means that "the application is independent of the storage structure and access strategy of data". In other words, The ability to modify the schema definition in one level should not affect the schema definition in the next higher level.
There are two types of independence,
Logical Data Independence: Modification in logical level should affect the view level
Physical Data Independence: Modification in physical level should not affect the logical level.

Q : What is Data Model?
A : A collection of conceptual tools for describing the data, data relationships data semantics and constraints.

Q : What is an Entity set?
A : Entity set is a collection of all entities of a particular entity type in the database.

Q : What is E-R model?
A : This data model is based on the real world that consists of basic objects called entities and of relationship among these objects. Entities are described in a database by a set of attributes.

Q : Name of sub-systems of a RDBMS?
A : There are many types of sub systems in RDBMS I/O, Security, Language Processing, Process Control, Storage Management, Logging and Recovery, Distribution Control, Transaction Control, Memory Management, Lock Management.

Q : How communicate with an RDBMS?
Communicate with an RDBMS using Structured Query Language (SQL)

Q :What’s the job of the information stored in data-dictionary?
A : The information in the data dictionary validates the existence of the objects, provides the access to them, and maps the actual physical storage location.

Q : What’s a database Trigger?
A : A database trigger is a PL/SQL block that can be defined to automatically execute for insert, update, and delete statements against a table. The trigger can be defined to execute once for the entire statement or once for every row that is inserted, updated, or deleted. For any one table, there are twelve events for which you can define database triggers. A database trigger can call the database procedures that are also written in PL/SQL.

Q : What is a Transaction Manager?
Transaction manager is a program module, which ensures that the database, remains in a consistent state despite of system failures and concurrent transaction execution proceeds without conflicting.

Q : What is Buffer Manager?
Buffer manager is a program module, which is responsible for fetching data from disk storage into the main memory and deciding what data to be cache in memory.

Q : What is File Manager?
File manager is a program module, which manages the allocation of space on disk storage and data structure used to the represent information stored on a disk.

Q : What is DDL?
A : A data base schema is specified by a set of definitions expressed by a special language called in DDL.

Q: What is SDL ?
Storage Definition language is to specify the internal schema. This language may specify the mapping between two schemas.

Q : What’s a DDL Interpreter?
A : DDL interprets is a DDL statements and record them in tables containing meta data.

Q : What is a query?
A : A query with respect to DBMS relates to user the commands that are used to interact with a data base. The query language can be classified into the data definition language (DDL)and data manipulation language(DML).

Your Ad Here