0
Q:

What is the output of this program?

#include
        using namespace std;
        void fun(int x, int y)
        {
            x = 20;
            y = 10;
        }
        int main()
        {
            int x = 10;
            fun(x, x);
            cout << x;
            return 0;
        }

A) 10 B) 20
C) compile time error D) none of these

Answer:   A) 10



Explanation:

In this program, we called by value so the value will not be changed, So the output is 10

Subject: C++
Q:

What is the scope resolution operator?

Answer

Scope resolution operator allows a program to reference an identifier in the global scope that is hidden by another identifier with the same name in the local scope.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

1 3604
Q:

Difference between Stack and Queue

Answer

Stack is a collection of objects that works in LIFO (Last in First out) mechanism while Queue is FIFO (First in First out). This means that the object that is inserted first is removed last in a stack while an object that is inserted first is removed first in a queue.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 4736
Q:

What do you mean by stack unwinding?

Answer

Stack unwinding is a process of calling all destructors for all automatic objects constructed at run time when an exception is thrown. Destructors are called between the places where the exception was thrown and where it is caught.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 2511
Q:

What is a Wrapper class?

Answer

Wrapper classes wrap primitive values in a class and offers utility to access them through objects. Some of the primitive wrapper data types are:


Byte, short, int, long, float, double, char, Boolean.


Example: 


Create a class name VectorAdd to populate it with integer values using the add(int, object) method.


public class VectorAdd


{


       public static void main(String argv[])


       {


             Vector v = new Vector();


             v.add(0,new Integer(10));


             v.add(1,new Integer(20));


             v.add(2,new Integer(30));


             for(int i=0; i < v.size();i ++)


             {


                  Integer iw =(Integer) v.get(i);


                  System.out.println(iw);


             }


       }


}

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 3267
Q:

Exlpain STL.

Answer

STL stands for Standard Template Library. It is a library of container templates approved by the ANSI committee for inclusion in the standard C++ specification.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 2679
Q:

.What are Stacks? Give an example where they are useful.

Answer

A Stack is a linear structure in which insertions and deletions are always made at one end i.e the top - this is termed as last in, first out (LIFO). Stacks are useful when we need to check some syntex errors like missing parentheses. 

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 3222
Q:

What are the advantages of using friend classes?

Answer

- Friend classes are useful when a class wants to hide features from users which are needed only by another, tightly coupled class. 


- Implementation details can be kept safe by providing friend status to a tightly cohesive class.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 3479
Q:

Explain one-definition rule (ODR).

Answer

According to one-definition rule, C++ constructs must be identically defined in every compilation unit they are used in. 


As per ODR, two definitions contained in different source files are called to be identically defined if they token-for-token identical. The tokens should have same meaning in both source files. 


Identically defined doesn’t mean character-by-character equivalence. Two definitions can have different whitespace or comments and yet be identical.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

0 2407