0% found this document useful (0 votes)
38 views32 pages

PPP - CPP - 01 - Google Forms

The document contains a series of multiple-choice questions (MCQs) related to C++ programming concepts, including syntax, functions, and error handling. Each question is followed by the correct answer, providing a comprehensive overview of key C++ topics. The format suggests it is intended for an online test or quiz format.

Uploaded by

Ram Bhardwaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views32 pages

PPP - CPP - 01 - Google Forms

The document contains a series of multiple-choice questions (MCQs) related to C++ programming concepts, including syntax, functions, and error handling. Each question is followed by the correct answer, providing a comprehensive overview of key C++ topics. The format suggests it is intended for an online test or quiz format.

Uploaded by

Ram Bhardwaj
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1/9/25, 1:03 C++ Online Test

PM 01

C++ MCQs QUESTIONS

[Link] 1/32
ayy_baeOrvgoFCT3ywbKLuw/edit
1/9/25, 1:03 C++ Online Test
PM 01
1. Which of the following is called insertion/put to
operator?

a) <<

b) >>

c) >

d) <

Ans. ( A )

2. A language which has the capability to generate new data types are called

a) Extensible

b) Overloaded

c) Encapsulated

d) Reprehensible

Ans. ( A )

3. Which of the following escape sequence represents carriage


return?

a) \r

b) \n

c) \n\r

d) \c

Ans. ( A )

[Link] 2/32
ayy_baeOrvgoFCT3ywbKLuw/edit
1/9/25, 1:03 C++ Online Test
PM 01

4. Which function is used to write a single character to console in C++?

a) [Link](ch)

b) [Link](ch)

c) write(ch)

d) printf(ch)

Ans. ( A )

[Link] 3/32
ayy_baeOrvgoFCT3ywbKLuw/edit
1/9/25, 1:03 C++ Online Test
PM 01
5. Which function is used to read a single character from the console in C++?

a) [Link](ch)

b) getline(ch)

c) read(ch)

d) scanf(ch)

Ans. ( A )

6. What are the formal parameters in


C++? *

a) Parameters with which functions are called

b) Parameters which are used in the definition of the function

c) Variables other than passed parameters in a function

d) Variables that are never used in the function

Ans. ( A )

7. What are the actual parameters in C++?

a) Parameters with which functions are called

b) Parameters which are used in the definition of a function

c) Variables other than passed parameters in a function

d) Variables that are never used in the function

Ans. ( A )

8. Which of the following is the correct syntax of including a user defined


header files
[Link] 4/32
ayy_baeOrvgoFCT3ywbKLuw/edit
1/9/25, 1:03 C++ Online Test
PM 01
in C++?

a) #include <userdefined.h>

b) #include <userdefined>

c) #include “userdefined”

d) #include [userdefined]

Ans. ( C )

[Link] 5/32
ayy_baeOrvgoFCT3ywbKLuw/edit
1/9/25, 1:03 C++ Online Test
PM 01
9. What happens if the following program is executed in C and C++?

a) Error in both C and C++

b) Warning in both C and C++

c) Error in C++ but Warning in C

d) Error in C but Warning in C++

Ans. ( C )

10. What happens if the following line is executed in C and C++?

int *p = malloc(10);

a) Error in both C and C++

b) Warning in both C and C++

c) Error in C++ and successful execution in C

d) Error in C and successful execution in C++

Ans. ( C )

[Link] 6/32
ayy_baeOrvgoFCT3ywbKLuw/edit
1/9/25, 1:03 C++ Online Test
PM 01
11. What happens if the following line is executed in C and C++?

const int a;

a) Error in both C and C++

b) Warning in both C and C++

c) Error in C and successful execution in C++

d) Error in C++ and successful execution in C

Ans. ( D )

12. Which of the following syntax for declaring a variable of struct


STRUCT can be used in both C and C++?

a) struct STRUCT S;

b) STRUCT S;

c) Both struct STRUCT S; and STRUCT S;

d) Both C and C++ have different syntax

Ans. ( A )

13. What will be the output of the following C++ code?

a) Output in C is 1 and in C++ is 4

b) Output in C is 4 and in C++ is 1

c) Output in C is 1 and in C++ is 1

d) Output in C is 4 and in C++ is 4


[Link] 7/32
ayy_baeOrvgoFCT3ywbKLuw/edit
1/9/25, 1:03 C++ Online Test
PM 01

Ans. ( C )

[Link] 8/32
ayy_baeOrvgoFCT3ywbKLuw/edit
1/9/25, 1:03 C++ Online Test
PM 01
14. What will be the output of the following program in both C and C++?

a) Output in C is 1 and in C++ is 4

b) Output in C is 4 and in C++ is 1

c) Output in C is 1 and in C++ is 1

d) Output in C is 4 and in C++ is 4

Ans. ( B )

15. What is name mangling in C+ +?

a) The process of adding more information to a function name so that it


can be distinguished from other functions by the compiler

b) The process of making common names for all the function of C++
program for better use

c) The process of changing the names of variable

d) The process of declaring variables of different types

Ans. ( A )

16. What is static binding?

a) The process of linking the actual code with a procedural call during run-time

b) The process of linking the actual code with a procedural call during compile-
time
c) The process of linking the actual code with a procedural call at any-time

d) All of the mentioned

Ans. ( B )
[Link] 9/32
ayy_baeOrvgoFCT3ywbKLuw/edit
1/9/25, 1:03 C++ Online Test
PM 01
17. What is dynamic binding?

a) The process of linking the actual code with a procedural call during run-time

b) The process of linking the actual code with a procedural call during compile-
time
c) The process of linking the actual code with a procedural call at any-time

d) All of the mentioned

Ans. ( A )

18. Which of the following is the correct difference between cin and scanf()?

a) both are the same

b) cin is a stream object whereas scanf() is a function

c) scanf() is a stream object whereas cin is a function

d) cin is used for printing whereas scanf() is used for reading input

Ans. ( B )

19. Why this pointer is used?

a) To access the members of a class which have the same name


as local variables in that scope

b) To access all the data stored under that class

c) To access objects of other class

d) To access objects of other variables

Ans. ( A )

[Link] 10/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
20. Which of the following is correct about static polymorphi
sm?

a) In static polymorphism, the conflict between the function call is


resolved during the compile time

b) In static polymorphism, the conflict between the function call is


resolved during the run time

c) In static polymorphism, the conflict between the function call is never


resolved during the execution of a program

d) In static polymorphism, the conflict between the function call is


resolved only if it required

Ans. ( A )

21. What is std in C+ +?

a) std is a standard class in C++

b) std is a standard namespace in C++

c) std is a standard header file in C++

d) std is a standard file reading header in C++

Ans. ( B )

22. What will be the output of the following C++ code?

a) Hello World

b) Compile-time error
[Link] 11/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
c) Run-time error

d) Segmentation fault

Ans. ( B )

[Link] 12/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
[Link] of the following syntax can be used to use a member
of a namespace without including that namespace ?

a) namespace::member

b) namespace->member

c) [Link]

d) namespace~member

Ans. ( A )

24. Which of the following C++ code will give error on compilation
?

a) Both code 1 and code 2

b) Code 1 only

c) Code 2 only

d) Neither code 1 nor code 2

Ans. ( D )

[Link] 13/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
[Link] of the following approach is used by C+ +?

a) Top-down

b) Bottom-up

c) Left-right

d) Right-left

Ans. ( B )

26. Which of the following explains the overloading of functions?

a) Virtual polymorphism

b) Transient polymorphism

c) Ad-hoc polymorphism

d) Pseudo polymorphism

Ans. ( C )

27. Which concept means the addition of new components to a


program as it runs?

a) Data hiding

b) Dynamic binding

c) Dynamic loading

d) Dynamic typing

Ans. ( C )

[Link] 14/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
28. What will be the output of the following C++ code?

a) 9

b) Garbage value

c) Error

d) Segmentation fault

Ans. ( A )

29. What will be the output of the following C++ code?

a) 10

b) Garbage value

c) Error

d) Segmentation fault

Ans. ( C )

[Link] 15/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
30. What will be the output of the following C++ code?

a) 0 0

b) Garbage values

c) Compile error

d) Segmentation fault

Ans. ( C )

[Link] 16/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
31. What will be the output of the following C++ code?

a) fun() is static

b) Compile-time Error

c) Run-time Error

d) Nothing is printed

Ans. ( B )

32. Which of the following is correct about static variables?

a) Static functions do not support polymorphism

b) Static data members cannot be accessed by non-static member functions

c) Static data members functions can access only static data members

d) Static data members functions can access both static and non-
static data members

Ans. ( C )

[Link] 17/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
33. What does ‘\a’ escape code represent?

a) alert

b) backslash

c) tab

d) form feed

Ans. ( A )

34. What is the size of wchar_t in C+ +?

a) 2

b) 4

c) 2 or 4

d) Based on the number of bits in the system

Ans. ( D )

35. What will be the output of the following C++ code?

a) 15

b) 18
[Link] 18/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
c) garbage value

d) compile time error

Ans. ( D )

[Link] 19/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
36. What will be the output of the following C++ code?

a) -15

b) -30

c) compile time error

d) garbage value

Ans. ( B )

37. What will be the output of the following C++ code?

a) ABC

b) ABCD

c) AB

d) AC

[Link] 20/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
Ans. ( A )

[Link] 21/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
38. What will be the output of the following C++ code?

a) 6553

b) 6533

c) 6522
d) 12200

Ans. ( B )

39.

[Link] 22/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
What will be the output of the following C++ code?

a) Compiler error

b) 12

c) 10

d) Empty

Ans. ( C )

40. In C++, what is the sign of character data type by default?

a) Signed

b) Unsigned

c) Implementation dependent

d) Unsigned Implementation

Ans. ( C )

41. Suppose in a hypothetical machine, the size of char is 32 bits.


What would sizeof(char) return?

a) 4

b) 1

c) Implementation dependent

d) Machine dependent

[Link] 23/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
Ans. ( B )

[Link] 24/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
42. What constant defined in <climits> header returns the number
of bits in a char?
a) CHAR_SIZE

b) SIZE_CHAR

c) BIT_CHAR

d) CHAR_BIT

Ans. ( D )

43. What is size of generic pointer in C++ (in 32-bit platform)?

a) 2

b) 4

c) 8

d) 0

Ans. ( B )

44. What will be the output of the following C++ code?

a) 15 18 21

b) 21 21 21

c) 24 24 24

d) Compile time error

[Link] 25/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01

Ans. ( B )

[Link] 26/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
45. What will be the output of the following C++ 1 point
code? *

a) ava

b) java

c) c++

d) compile time error

Ans. ( A )

[Link] 27/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
[Link] will be the output of the following C++ 1 point
code? *

a) 10,20,30,40,50,

b) 1020304050

c) compile error

d) runtime error

Ans. ( A )

[Link] 28/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
47. What will be the output of the following C++ 1 point
code? *

a) 4

b) 5

c) address of arr

d) 7

Ans. ( C )

48. What is the use of dynamic_cast 1 point


operator? *

a) it converts virtual base class to derived class

b) it converts the virtual base object to derived objects

c) it will convert the operator based on precedence

d) it converts the virtual base object to derived class

Ans. ( A )

49. What is the use of the indentation in 1 point


c++? *

a) distinguishes between comments and code

b) r distinguishes between comments and outer data

c) distinguishes between comments and outer data

[Link] 29/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
d) r distinguishes between comments and inner data

Ans. ( A )

[Link] 30/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01
50. What will happen when we use void in argument 1 point
passing? *

a) It will not return value to its caller

b) It will return value to its caller

c) May or may not depend on the declared return type of the function,
the passed arguments are different than the function return type

d) It will return value

Ans. ( A )

[Link] 31/
ayy_baeOrvgoFCT3ywbKLuw/edit 32
1/9/25, 1:03 C++ Online Test
PM 01

[Link] 32/
ayy_baeOrvgoFCT3ywbKLuw/edit 32

You might also like