1
Q:

What is the output of this program?

#include
        using namespace std;
        struct sec {
            int a;
            char b;
        };
        int main()
        {
            struct sec s ={25,50};
            struct sec *ps =(struct sec *)&s;
            cout << ps->a << ps->b;
            return 0;
        }

A) 252 B) 253
C) 254 D) 262

Answer:   A) 252



Explanation:

In this program, We are dividing the values of a and b, printing it.

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 3890
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 4912
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 2749
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 3507
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 2937
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 3409
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 3738
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 2703