C++ Language | 10 Minute‐Test 4


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.

What does a escape code represent ?

A.
alert
B.
backslash
C.
tab
D.
form feed

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Because a is used to produce a beep sound.

2.

What happens when a null pointer is converted into bool ?

A.
An error is flagged
B.
bool value evaluates to true
C.
bool value evaluates to false
D.
the statement is ignored

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

A pointer can be implicitly converted to a bool. A nonzero pointer converts to true and zerovalued
pointer converts to false.

3.

What will be the output of this program ?

  1.     #include <iostream>

        using namespace std ;

        int main()

        {

            char c = 74 ;

            cout << c ;

            return 0;

        }

     

A.
A
B.
N
C.
J
D.
I

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

The literal value for 74 is J. So it will be printing J.


4.

What will be output of this function?

int main ()

{

register int i = 1 ;

int * ptr = & i;

cout << *ptr ;

return 0 ;

}

 

A.
0
B.
1
C.
Compiler Error may be possible
D.
Run time error may be possible

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

Using & on a register variable may be invalid, since the compiler may store
the variable in a register, and finding the address of it is illegal.

5.

What is the output of this program ?

#include <iostream>

using namespace std;

int main ()

{

char arr [20 ] ;

int i;

for( i = 0 ; i < 10 ; i++ )

*( arr + i ) = 65 + i ;

*( arr + i ) = '\0 ';

cout << arr;

return( 0) ;

}

 

A.
ABCDEFGHIJ
B.
AAAAAAAAAA
C.
JJJJJJJJ
D.
none of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Each time we are assigning 65 + i. In first iteration i = 0 and 65 is assigned.
So it will print from A to J.
$ g++ point1.cpp
$ a.out
ABCDEFGHIJ

6.

What is the output of the following program ?

  1. #include <iostream>
  2. using namespace std;
  3. int main ()
  4. {
  5. int a = 10 ;
  6. if ( a < 10 ) {
  7. for ( i = 0 ; i < 10 ; i++ )
  8. cout << i;
  9. }
  10. else {
  11. cout << i;
  12. }
  13. return 0 ;
  14. }

A.
0123456789
B.
123456789
C.
0
D.
error

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

We will get compilation error because ‘i’ is an undeclared identifier.

7.

What is the use of functor ?

A.
It makes the object “callable” like a function.
B.
It makes the class “callable” like a function.
C.
It makes the attribute “callable” like a function.
D.
none of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

None

8.

What is the use of function call operator ?

A.
overloading the methods
B.
overloading the objects
C.
overloading the parameters
D.
none of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None

9.

What is the output of the following program ?

  1. #include <iostream>

        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

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

In this program, We are dividing the values of a and b, printing it.
Output:
$ g++ stu5.cpp
$ a.out
252



10.

What is the output of this program ?

  1. #include <stdio.h>

        using namespace std ;

        int main()

        {

            int a = 21 ;

            int c ;

            c = a++;

            cout << c ; 

            return 0;

        }

     

A.
21
B.
22
C.
23
D.
20

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Explanation:value of ‘a’ will be stored in c and then only it will be incremented.
Output:
$ g++ incre.cpp
$ a.out
21

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