0
Q:

# What do vectors represent?

 A) Static arrays B) Dynamic arrays C) Stack D) Queue

Explanation:

Vectors are sequence containers representing arrays that can change in size.

Subject: C++ - Technology
Q:

Which of the following is not a correct variable type?

 A) real B) char C) float D) double

Explanation:

A variable provides us with named storage that our programs can manipulate. Each variable in C++ has a specific type, which determines the size and layout of the variable's memory the range of values that can be stored within that memory and the set of operations that can be applied to the variable.

The name of a variable can be composed of letters, digits, and the underscore character. It must begin with either a letter or an underscore. Upper and lowercase letters are distinct because C++ is case-sensitive −

Basic types of variables:

1. bool

Stores either value true or false.

2. char

Typically a single octet (one byte). This is an integer type.

3. int

The most natural size of an integer for the machine.

4. float

A single-precision floating point value.

5. double

A double-precision floating point value.

6. void

Represents the absence of type.

7. wchar_t

A wide character type.

0 123
Q:

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

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.

1072
Q:

Give an example for the use of volatile keyword in c++ ?

Most of the times compilers will do optimization to the code to speed up the program. For example in the below code,

int k = 15;
while( k == 15)

{
// Do something
}

compiler may think that value of 'k' is not getting changed in the program and replace it with 'while(true)', which will result in an infinite loop. In actual scenario, the value of 'k' may be getting updated from outside of the program.

Volatile keyword is used to tell compiler that the variable declared using 'volatile' may be used from outside the current scope, so that compiler won't apply any optimization. This matters only in case of multi-threaded applications.

In the above example if variable 'k' was declared using volatile, compiler will not optimize it. In shot, value of the volatile variables will be read from the memory location directly.

1738
Q:

Values that are used to end loops are referred to as _____ values.

 A) stop B) sentinel C) end D) finish

Explanation:

3 1397
Q:

Which of the following type casts will convert an Integer variable named amount to a Double type ?

 A) (int to double) amount B) int (amount) to double C) int to double(amount) D) (double) amount

Explanation:

2 1135
Q:

What is conversion operator ?

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.

1055
Q:

When should we use container classes instead of arrays?

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.

Subject: C++ - Technology

1469
Q:

What is a container class?