techpreparation-homepage

Home  Interview Questions  Certifications  Aptitude Questions  Tutorials  Placement Papers  Search  Resume  Soft Skills  Video  Forum  Blog


Technical Interview Questions

C++ Interview Questions
C# Interview Questions
C Interview Questions
                              .........More

Aptitude Interview Questions
C ++ Aptitude Question 2
C Aptitude Questions
                              .........More

Tutorials
C Tutorial
C++ Tutorial
                              .........More

Programming Source Codes
C/C++ Source Codes
C# Source Codes
                              .........More

Online Quiz
C Online Quiz
C++ Online Quiz
                              .........More

Soft Skills
Communication Skills
Leadership Skills
                              .........More

 

  

C/C++ Aptitude Questions and Answers



Differentiate between declaration and definition in C++.
A declaration introduces a name into the program; a definition provides a unique description of an entity (e.g. type, instance, and function). Declarations can be repeated in a given scope, it introduces a name in a given scope. There must be exactly one definition of every object, function or class used in a C++ program.
A declaration is a definition unless:
  it declares a function without specifying its body,
  it contains an extern specifier and no initializer or function body,
  it is the declaration of a static class data member without a class definition,
  it is a class name definition,
  it is a typedef declaration.
            A definition is a declaration unless:
  it defines a static class data member,
  it defines a non-inline member function.

What is cloning?
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.

Describe the main characteristics of static functions.
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.             

Will the inline function be compiled as the inline function always? Justify.
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.

Define a way other than using the keyword inline to make a function inline.
The function must be defined inside the class.  

How can a '::' operator be used as unary operator?
The scope operator can be used to refer to members of the global namespace. Because the global namespace doesnt 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.

What is placement new?
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.

OOAD
What do you mean by analysis and design?

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.

What are the steps involved in designing?
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.

What are the main underlying concepts of object orientation?
Objects, messages, class, inheritance and polymorphism are the main concepts of object orientation.

What do u meant by "SBI" of an object?
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.

Page Numbers :   1         2         3         4         5         6         7         8         9

Next >> C/C++ Aptitude Questions and Answers 2

Have a Question ? post your questions here. It will be answered as soon as possible.

Check Placement Papers for more IT Companies Paper