C++ Interview questions Part 13

C++ interview question:List out some of the object-oriented methodologies?
Answer: 
Ø Object Oriented Development (OOD) (Booch 1991,1994).
Ø Object Oriented Analysis and Design (OOA/D) (Coad and Yourdon 1991).
Ø Object Modelling Techniques (OMT) (Rumbaugh 1991).
Ø Object Oriented Software Engineering (Objectory) (Jacobson 1992).
Ø Object Oriented Analysis (OOA) (Shlaer and Mellor 1992). The Fusion Method (Coleman 1991)

C++ interview question: Name some pure object oriented languages?
Answer:
Ø Smalltalk,
Ø Java,
Ø Eiffel,
Ø Sather.

C++ interview question: What is an USECASE? Why it is needed? 
Answer:Use Case is a description of a set of sequence of actions that a system performs that yields an observable result of value to a particular action. In SSAD process <=> In OOAD USECASE. It is represented elliptically.

C++ interview question :Can we generate a C++ source code from the binary file?
Answer: Technically this is possible, but in my knowledge their no such software available yet. Why this is possible? In program flow we do like this to generate binary file. High level language programming code -low level programming code- hex code- binary code. How we can do reverse can be illustrated with this example. When I type 0 on screen the ASCII equivalent is 65 and so the binary code will be by converting 65 (01010 0101) so I can recognize this and decode this. Same technique can be used. Some secret mission defense org. I heard have this code splitter from binary to assembly language (low level language)/ Converter type devices available, they use them for secret national purpose.

C++ interview question : What is a memory leak? How can we avoid it? 
Answer :A memory leak can be avoided by making sure that whatever memory has been dynamically allocated will be cleared after the use of the same. for example

int main()
{ char *myCharData[20];
for (int nLoop =0;nLoop < 20; ++nLoop) { myCharData[nLoop ] = new char[256];
strcpy(myCharData[nLoop],"SABITH");
......
}
........................
/*Some manipulations here using myCharData*/
/*Now here we have to clear the data. The place can vary according to ur program. This being a simple program,u can clear at the end*/
for(int nLoop =0;nLoop < 20; ++nLoop)
{
delete[] myCharData[nLoop ];
}
return 0;

C++ interview question: What is virtual class and friend class? 
Answer: Friend classes are used when two or more classes are designed to work together and virtual base class aids in multiple inheritance

C++ interview question:Why does the function arguments are called as "signatures"?
Answer: The arguments distinguish functions with the same name (functional polymorphism). The name alone does not necessarily identify a unique function. However, the name and its arguments (signatures) will uniquely identify a function.In real life we see suppose, in class there are two guys with same name, but they can be easily identified by their signatures. The same concept is applied here.

ex: class person
{
public:
char getsex();
void setsex(char);
void setsex(int);
};
In the above example we see that there is a function setsex() with same name but with different signature.

Read more...

C++ Interview questions Part 12

C++ interview question:What is cloning? 
Answer:An object can carry out copying in two ways i.e. it can set itself to be a copy of another object, or it can return a copy of itself. The latter process is called cloning.

C++ interview question:Describe the main characteristics of static functions.
Answer:The main characteristics of static functions include,
Ø It is without the a this pointer,
Ø It can't directly access the non-static members of its class
Ø It can't be declared const, volatile or virtual.
Ø It doesn't need to be invoked through an object of its class, although for convenience, it may.

C++ interview question:Will the inline function be compiled as the inline function always?Justify.  

Answer:An inline function is a request and not a command. Hence it won't be compiled as an inline function always.
Explanation:  
Inline-expansion could fail if the inline function contains loops, the address of an inline function is used, or an inline function is called in a complex expression. The rules for inlining are compiler dependent.

C++ interview question:Define a way other than using the keyword inline to make a function inline.
Answer:The function must be defined inside the class.

C++ interview question:How can a '::' operator be used as unary operator?
Answer:The scope operator can be used to refer to members of the global namespace. Because the global namespace doesn’t have a name, the notation :: member-name refers to a member of the global namespace. This can be useful for referring to members of global namespace whose names have been hidden by names declared in nested local scope. Unless we specify to the compiler in which namespace to search for a declaration, the compiler simple searches the current scope, and any scopes in which the current scope is nested, to find the declaration for the name.

C++ interview question:What is placement new?
Answer:When you want to call a constructor directly, you use the placement new. Sometimes you have some raw memory that's already been allocated, and you need to construct an object in the memory you have. Operator new's special version placement new allows you to do it.

class Widget
{  
public :
Widget(int widgetsize);  
Widget* Construct_widget_int_buffer(void *buffer,int widgetsize)
{
return new(buffer) Widget(widgetsize);
}
};
This function returns a pointer to a Widget object that's constructed within the buffer passed to the function. Such a function might be useful for applications using shared memory or memory-mapped I/O, because objects in such applications must be placed at specific addresses or in memory allocated by special routines.


C++ interview question:What do you mean by analysis and design?
Answer:
Analysis:
Basically, it is the process of determining what needs to be done before how it should be done. In order to accomplish this, the developer refers the existing systems and documents. So, simply it is an art of discovery.
Design:
It is the process of adopting/choosing the one among the many, which best accomplishes the users needs. So, simply, it is compromising mechanism.


C++ interview question:What are the steps involved in designing?
Answer:Before getting into the design the designer should go through the SRS prepared by the System Analyst.
The main tasks of design are Architectural Design and Detailed Design.
In Architectural Design we find what are the main modules in the problem domain.
In Detailed Design we find what should be done within each module.


C++ interview question:What are the main underlying concepts of object orientation?
Answer:Objects, messages, class, inheritance and polymorphism are the main concepts of object orientation.


C++ interview question:What do u meant by "SBI" of an object?
Answer:SBI stands for State, Behavior and Identity. Since every object has the above three.
Ø State:
It is just a value to the attribute of an object at a particular time.
Ø Behaviour:
It describes the actions and their reactions of that object.
Ø Identity
An object has an identity that characterizes its own existence. The identity makes it possible to distinguish any object in an unambiguous way, and independently from its state.


C++ interview question:Differentiate persistent & non-persistent objects?
Answer:Persistent refers to an object's ability to transcend time or space. A persistent object stores/saves its state in a permanent storage system with out losing the information represented by the object.
A non-persistent object is said to be transient or ephemeral. By default objects are considered as non-persistent.


C++ interview question:What do you meant by active and passive objects?
Answer:Active objects are one which instigate an interaction which owns a thread and they are responsible for handling control to other objects. In simple words it can be referred as client.        Passive objects are one, which passively waits for the message to be processed. It waits for another object that requires its services. In simple words it can be referred as server.


C++ interview Question:What is meant by software development method?
Answer:Software development method describes how to model and build software systems in a reliable and reproducible way. To put it simple, methods that are used to represent ones' thinking using graphical notations.

Read more...

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Back to TOP