Sample Questions Best site for GRE, LSAT, SAT, GMAT, TOEFL, CCNA, CCSA and interview sample questions  

Technical Sample Questions : C |  C++ |  Oracle |  Java | Unix |  Operating Systems |  Data Structure

Sample Technical Questions

C++ and OOPS Sample Question

  1. What are proxy objects?

    Answer:

    Objects that points to other objects are called proxy objects or surrogates. Its an object that provides the same interface as its server object but does not have any functionality. During a method invocation, it routes data to the true server object and sends back the return value to the object.

  2. Differentiate between declaration and definition in C++.

    Answer:

    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.
  3. 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.
  4. 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.
  5. 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.
  6. Define a way other than using the keyword inline to make a function inline.

    Answer:

    The function must be defined inside the class.
  7. 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.
  8. 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.

« Previous || Next »

C++ Sample Question number : 1-3 | 4-7 | 8-10 | 11-13 | 14-21 | 22-28 | 29-35 | 36-42 | 43-49 | 50-54 | 55-58 | 59-66 | 67-73 | 74-80
Sample Test Questions
GRE Sample Questions
CAT Sample Questions
GMAT Sample Questions
TOEFL Sample Questions
ACT Sample Questions
SAT Sample Questions
LSAT Sample Questions
PSAT Sample Questions
MCAT Sample Questions
PMP Sample Questions
GED Sample Questions
ECDL Sample Questions
DMV Sample Questions
CCNA Sample Questions
MCSE Sample Questions
Network+ Sample Questions
A+ Sample Questions
Technical Sample Questions
WASL Sample Questions
CISA Sample Questions

Other Sample Questions
Sample Interview Questions
Sample Teacher Interview Questions
Sample Citizenship Questions
Accuplacer Sample Questions
Science Bowl sample Questions
Driving Test Sample Questions
Sample Survey Questions Sample Essay Questions
Sample Behavioral Interview Questions

Copyright © 2004-2013, Best BSQ. All Rights Reserved.