C++ Questions

Q:

How the different permutations are ordered in c++?

A) Compare lexicographicaly to each other elements B) By finding the highest element in the range
C) By finding the lowest element in the range D) None of the mentioned
 
Answer & Explanation Answer: A) Compare lexicographicaly to each other elements

Explanation:
Report Error

View Answer Report Error Discuss

Filed Under: C++

1 4279
Q:

What is meant by template specialization?

A) It will have certain data types to be fixed. B) It will make certain data types to be dynamic.
C) Certain data types are invalid D) None of the mentioned
 
Answer & Explanation Answer: A) It will have certain data types to be fixed.

Explanation:

In the template specialization, it will make the template to be specific for some data types.

Report Error

View Answer Report Error Discuss

Filed Under: C++

1 4191
Q:

When should we use container classes instead of arrays?

Answer

It is advisable to use container classes of the STL so that you don’t have to go through the pain of writing the entire code for handling collisions, making sure its working well, testing it repeatedly with an overhead of time consumption.


Suppose you have some data that has values associated with strings and its fields consist of grades> in this situation you can directly use hash table instead of having it created by yourself.

Report Error

View answer Workspace Report Error Discuss

Subject: C++

8 4129
Q:

What is meant by exception specification?

A) A function is limited to throwing only a specified list of exceptions. B) A catch can catch all types of exceptions.
C) A function can throw any type of exceptions. D) none of the mentioned
 
Answer & Explanation Answer: A) A function is limited to throwing only a specified list of exceptions.

Explanation:

C++ provides a mechanism to ensure that a given function is limited to throwing only a specified list of exceptions. It is called as exception specification.

Report Error

View Answer Report Error Discuss

Filed Under: C++

0 4107
Q:

A binary tree with 7 nodes will have how many null branches?

A) 6 B) 7
C) 8 D) 5
 
Answer & Explanation Answer: C) 8

Explanation:

A binary tree with n nodes has exactly n+1 null nodes

Report Error

View Answer Report Error Discuss

Filed Under: C++

1 4086
Q:

What do you mean by friend function in C++ ?

Answer

Friends can be either functions or other classes. The class grants friends unlimited access privileges.

* The declaration of the function should be preceded by the keyword 'friend'.
* The function definition will not use the keyword or the scope operator '::'.


Thus, a friend function is an ordinary function or a member of another class.

Report Error

View answer Workspace Report Error Discuss

15 4048
Q:

How many types of constructor are there in C++?

A) 1 B) 2
C) 3 D) 4
 
Answer & Explanation Answer: C) 3

Explanation:

There are three types of constructor in C++. They are Default constructor, Parameterized constructor, Copy constructor.

Report Error

View Answer Report Error Discuss

Filed Under: C++

1 4016
Q:

What is conversion operator ?

Answer

Class can have a public method for specific data type conversions.
for example:
class B
{
double value;
public  B(int i )
operator double()
{
return value;
}
};
B BObject;
double i = BObject; // assigning object to variable i of type double.
now conversion operator gets called to assign the value.

Report Error

View answer Workspace Report Error Discuss

11 3994