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 is class invariant?

    Answer:

    A class invariant is a condition that defines all valid states for an object. It is a logical condition to ensure the correct working of a class. Class invariants must hold when an object is created, and they must be preserved under all operations of the class. In particular all class invariants are both preconditions and post-conditions for all operations or member functions of the class.

  2. What do you mean by Stack unwinding?

    Answer:

    It is a process during exception handling when the destructor is called for all local objects between the place where the exception was thrown and where it is caught.
  3. Define precondition and post-condition to a member function.

    Answer:

    Precondition:
    A precondition is a condition that must be true on entry to a member function. A class is used correctly if preconditions are never false. 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:
    A post-condition is 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 if 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.

  4. What are the conditions that have to be met for a condition to be an invariant of the class?

    Answer:

    The condition should hold at the end of every constructor.
    The condition should hold at the end of every mutator(non-const) operation.
  5. What are proxy objects?

    Answer:

    Objects that stand for other objects are called proxy objects or surrogates.

    Example:

    template
                      class Array2D 
                      {
                             public:
                                  class Array1D
                                   {
                		 public:
                                     T& operator[] (int index);
                                     const T& operator[] (int index) const;
                                     ...
                                   };
                                  Array1D operator[] (int index);
                                  const Array1D operator[] (int index) const;
                                  ...
                       };
           
    The following then becomes legal:
    Array2Ddata(10,20);
    ........
    cout«data[3][6]; // fine

    Here data[3] yields an Array1D object and the operator [] invocation on that object yields the float in position(3,6) of the original two dimensional array. Clients of the Array2D class need not be aware of the presence of the Array1D class. Objects of this latter class stand for one-dimensional array objects that, conceptually, do not exist for clients of Array2D. Such clients program as if they were using real, live, two-dimensional arrays. Each Array1D object stands for a one-dimensional array that is absent from a conceptual model used by the clients of Array2D. In the above example, Array1D is a proxy class. Its instances stand for one-dimensional arrays that, conceptually, do not exist.

  6. Name some pure object oriented languages.

    Answer:

    • Smalltalk,
    • Java,
    • Eiffel,
    • Sather.
  7. Name the operators that cannot be overloaded.

    Answer:

    sizeof . .* .-> :: ?:

« Previous || Next »

C++ Sample Question number : 1-3 | 4-7 | 8-10 | 11-13 | 14-21 | 22-28 | 29-35 | 6-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.