C++ Questions

Q:

What is the Standard Template Library?

Answer

A library of container templates approved by the ANSI committee for inclusion in the standard C++ specification. A programmer who then launches into a discussion of the generic programming model, iterators, allocators, algorithms, and such, has a higher than average understanding of the new technology that STL brings to C++ programming

Report Error

View answer Workspace Report Error Discuss

Subject: C++
Job Role: Software Architect

2 9956
Q:

Which of the following type of data member can be shared by all instances of its class?

A) Public B) Inherited
C) Static D) None
 
Answer & Explanation Answer: C) Static

Explanation:

Static members are shared by all the instances of the class

Report Error

View Answer Report Error Discuss

Filed Under: C++

2 9731
Q:

Which design patterns benefit from the multiple inheritance?

A) Adapter and observer pattern B) Code pattern
C) Glue pattern D) None of these
 
Answer & Explanation Answer: A) Adapter and observer pattern

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: C++

5 9604
Q:

What is the output of this program?

 #include
       using namespace std;
       int main()
       {
           int arr[] = {4, 5, 6, 7};
           int *p = (arr + 1);
           cout << arr;
           return 0;
       }

A) 4 B) 5
C) address of arr D) 7
 
Answer & Explanation Answer: C) address of arr

Explanation:

As we couted to print only arr, it will print the address of the array.

Report Error

View Answer Report Error Discuss

Filed Under: C++

0 9382
Q:

How do define the user-defined exceptions?

A) inheriting and overriding exception class functionality. B) overriding class functioality.
C) inheriting class functionality D) none of the mentioned
 
Answer & Explanation Answer: A) inheriting and overriding exception class functionality.

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: C++

4 9216
Q:

Which of the following is not the member of class?

A) Virtual function B) Static function
C) Friend function D) Const function
 
Answer & Explanation Answer: C) Friend function

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: C++
Job Role: Analyst , Database Administration , IT Trainer

19 8342
Q:

In which of the following we cannot overload the function?

A) return function B) caller
C) called function D) none of the mentioned
 
Answer & Explanation Answer: A) return function

Explanation:

While overloading the return function, it will rise a error, So we can’t overload the return function.

Report Error

View Answer Report Error Discuss

Filed Under: C++

2 8269
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 & Explanation Answer: A) 252

Explanation:

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

Report Error

View Answer Report Error Discuss

Filed Under: C++

1 8062