C++ Language | 10 Minute‐Test 5


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.

Which type is best suited to represent the logical values ?

A.
integer
B.
boolean
C.
character
D.
all of above

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

Logical values can be either true or false, so the boolean type is suited for it.

2.

Which of the following statements are false ?

A.
bool can have two values and can be used to express logical expressions.
B.
bool cannot be used as the type of the result of the function.
C.
bool can be converted into integers implicitly
D.
a bool value can be used in arithemetic expressions.

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

None

3.

How do we represent a wide character of the form wchar_t ?

A.
L’a’
B.
l’a’
C.
L[a] d) la

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

A wide character is always indicated by immediately preceding the character
literal by an L.

4.

What does the following statement mean ?
int (*fp)(char*)

A.
pointer to a pointer
B.
pointer to an array of chars
C.
pointer to function taking a char* argument and returns an int
D.
function taking a char* argument and returning a pointer to int

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

None

5.

What is the output of this program ?

#include <iostream>

using namespace std;

int main ()

{

char * ptr;

char Str [] = "abcdefg" ;

ptr = Str ;

ptr + = 5 ;

cout << ptr;

return 0 ;

}

 

A.
fg
B.
cdef
C.
defg
D.
abcd

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Pointer ptr points to string ‘fg’. So it prints fg.
Output:
$ g++ point.cpp
$ a.out
fg

6.

Which will be used with physical devices to interact from C++ program ?

A.
Programs
B.
Library
C.
Streams
D.
None of the above

Your Answer: Option (Not Answered)

Correct Answer: Option C

Explanation:

C++ library uses streams to operate with physical devices such as Keyboards, Printers,
Terminals or with any other type of files supported by the system.

7.

Pick out the correct statement.

A.
virtual functions does not give the ability to write a templated function.
B.
virtual functions does not give the ability to rewrite a templated function.
C.
virtual functions does give the ability to write a templated function.
D.
none of the mentioned

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

none

8.

Pick out the correct statement

A.
Preincrement is faster than postincrement.
B.
postincrement is faster than preincrement.
C.
Post increment is as fast as post increment
D.
None of the above

Your Answer: Option (Not Answered)

Correct Answer: Option A

Explanation:

Because preincrement take one byte instruction &
post increment takes two byte instruction.


9.

Which of the following is a properly defined structure ?

A.
struct {int a;}
B.
struct a_struct {int a;}
C.
struct a_struct int a;
D.
struct a_struct {int a;};v

Your Answer: Option (Not Answered)

Correct Answer: Option D

Explanation:

The a_struct is declared as structure name and its data element is a.


10.

What is the output of this program ?

  1.    #include <stdio.h>
  2.     using namespace std ;
  3.     int main()
  4.     {
  5.         int x = 5 , y = 5 ;
  6.         cout << ++ x << -- y << endl ;
  7.         return 0;
  8.     }

A.
55
B.
64
C.
46
D.
45

Your Answer: Option (Not Answered)

Correct Answer: Option B

Explanation:

The values will be preincemented and predecremented, So it will print as 64.
Output:
$ g++ incre2.cpp
$ a.out
64

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