C++ Language | 10 Minute‐Test 2


Instruction

  • Total number of questions : 10.
  • Time alloted : 10 minutes.
  • Each question carry 1 mark.
  • No Negative marks
  • DO NOT refresh the page.
  • All the best :-).

1.

Pick the odd one out

A.
Array Type
B.
Character Type
C.
Boolean Type
D.
Integer Type

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Array type is not the basic type and it is constructed using the basic type

2.

Find the odd one out:

A.
std::vector
B.
std::vector
C.
std::vector
D.
std::vector

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

std::vector is a specialized version of vector, which is used for
elements of type bool and optimizes for space. It behaves like the unspecialized version
of vector and the storage is not necessarily an array of bool values, but the library
implementation may optimize storage so that each value is stored in a single bit.

3.

Select the right option.
Given the variables p, q are of char type and r, s, t are of int type
1. t = (r * s) / (r + s);
2. t = (p * q) / (r + s);

A.
1 is true but 2 is false
B.
1 is false and 2 is true
C.
both 1 and 2 are true
D.
both 1 and 2 are false

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

Every character constant has an integer value. Also char belongs to the
integral type hence arithmetic and logical operations can be performed on them.

4.

  1. #include <iostream>

        using namespace std ;

        int main()

        {

            int a = 8 ;

            cout << "ANDing integer 'a' with 'true' :" << a && true ;

            return 0;

        }

     

A.
ANDing integer ‘a’ with ‘true’ :8
B.
ANDing integer ‘a’ with ‘true’ :0
C.
ANDing integer ‘a’ with ‘true’ :1
D.
None of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None

5.

What is the output of this program ?

#include <iostream>

using namespace std;

int main ()

{

int a = 5, b = 10 , c = 15 ;

int * arr[ ] = { &a, & b, & c };

cout << arr[ 1 ];

return 0 ;

}

 

A.
5
B.
10
C.
15
D.
Any Random number

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

Array element cannot be address of auto variable.
It can be address of static or extern variables.

6.

Can two functions declare variables(non static) with the same name ?

A.
No
B.
Yes
C.
Yes , but not an efficient way to write the program
D.
No, t gives run time error

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

We can declare variables with the same name in two functions
because their scope lies within the function.

7.

What is the output of this program ?

  1. #include
  2. using namespace std;
  3. void duplicate (int & a, int & b, int & c)
  4. {
  5. a * = 2 ;
  6. b * = 2 ;
  7. c * = 2 ;
  8. }
  9. int main ()
  10. {
  11. int x = 1 , y = 3 , z = 7 ;
  12. duplicate ( x, y, z) ;
  13. cout << x << y << z ;
  14. return 0 ;
  15. }

A.
1468
B.
2812
C.
2614
D.
None of these mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

We are passing the values by reference and modified the data on the function block.
Output:
$ g++ call1.cpp
$ a.out
2614

8.

In which form does the function call operator can be overloaded ?

A.
Static member function
B.
non-static member function
C.
dynamis_cast
D.
static_cast

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None



9.

The declaration of structure is also called as ?

A.
sructure creator
B.
structure signifier
C.
sructure specifier
D.
none of the above

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The structure declaration with open and close braces and
with a semicolon is also called structure specifier.

10.

How many types are there in increment/decrement operator ?

A.
1
B.
2
C.
3
D.
4

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

There are two types of increment/decrement. They are postfix and prefix.

Submit your test now to view the Results and Statistics with answer explanation.