FSc · Computer Science (Grade 12)

Unit 3 MCQs

50 solved multiple choice questions with answers.

Q1. C++ is a

  1. AOnly procedural language
  2. BObject-oriented programming language
  3. COnly markup language
  4. DAssembly language
Show answer
Answer: B. Object-oriented programming language
Report a mistake

Q2. A computer program is

  1. AOnly output
  2. BOnly data
  3. CA set of instructions given to a computer
  4. DOnly hardware
Show answer
Answer: C. A set of instructions given to a computer
Report a mistake

Q3. Header files in C++ are included using

  1. A#header
  2. B#import
  3. C#include
  4. D#define
Show answer
Answer: C. #include
Report a mistake

Q4. Reserved words (keywords) in C++

  1. AAre optional
  2. BCan be used freely
  3. CAre only for comments
  4. DCannot be used as variable names
Show answer
Answer: D. Cannot be used as variable names
Report a mistake

Q5. The statement terminator in C++ is

  1. AColon ( : )
  2. BSemicolon ( ; )
  3. CComma ( , )
  4. DPeriod ( . )
Show answer
Answer: B. Semicolon ( ; )
Report a mistake

Q6. Comments in C++ can be written using

  1. A// and /* */
  2. BOnly #
  3. COnly **
  4. DOnly --
Show answer
Answer: A. // and /* */
Report a mistake

Q7. A constant in C++ has

  1. AFixed value that cannot be changed
  2. BNo value
  3. CValue that can be changed
  4. DOnly integer value
Show answer
Answer: A. Fixed value that cannot be changed
Report a mistake

Q8. A variable is

  1. AA fixed value
  2. BA function only
  3. CA keyword
  4. DA named memory location that can hold a value
Show answer
Answer: D. A named memory location that can hold a value
Report a mistake

Q9. Rules for naming variables include

  1. ACan start with digit
  2. BCan be keywords
  3. CMust begin with letter or underscore
  4. DCan contain spaces
Show answer
Answer: C. Must begin with letter or underscore
Report a mistake

Q10. Basic data types in C++ include

  1. AOnly array
  2. BOnly string
  3. Cint, float, char, double, bool
  4. DOnly int
Show answer
Answer: C. int, float, char, double, bool
Report a mistake

Q11. The const qualifier is used to

  1. ADeclare a function
  2. BDeclare a class
  3. CDeclare a variable
  4. DDeclare a constant
Show answer
Answer: D. Declare a constant
Report a mistake

Q12. Type casting is

  1. AIncluding header files
  2. BDeclaring a variable
  3. CConverting one data type into another
  4. DWriting comments
Show answer
Answer: C. Converting one data type into another
Report a mistake

Q13. The extension of a C++ source file is usually

  1. A.java
  2. B.py
  3. C.cpp
  4. D.c
Show answer
Answer: C. .cpp
Report a mistake

Q14. The main() function is

  1. AOptional
  2. BA header file
  3. CThe entry point of a C++ program
  4. DOnly for classes
Show answer
Answer: C. The entry point of a C++ program
Report a mistake

Q15. cout is used for

  1. ABoth
  2. BNone
  3. CStandard output
  4. DStandard input
Show answer
Answer: C. Standard output
Report a mistake

Q16. cin is used for

  1. ABoth
  2. BNone
  3. CStandard output
  4. DStandard input
Show answer
Answer: D. Standard input
Report a mistake

Q17. The insertion operator is

  1. A>>
  2. B::
  3. C->
  4. D<<
Show answer
Answer: D. <<
Report a mistake

Q18. The extraction operator is

  1. A::
  2. B->
  3. C<<
  4. D>>
Show answer
Answer: D. >>
Report a mistake

Q19. endl is used to

  1. AInclude a file
  2. BInsert a new line and flush the buffer
  3. CEnd the program
  4. DDeclare a variable
Show answer
Answer: B. Insert a new line and flush the buffer
Report a mistake

Q20. Escape sequences start with

  1. AHash ( # )
  2. BBackslash ( \ )
  3. CAsterisk ( * )
  4. DForward slash ( / )
Show answer
Answer: B. Backslash ( \ )
Report a mistake

Q21. \n represents

  1. ANew line
  2. BBackspace
  3. CSpace
  4. DTab
Show answer
Answer: A. New line
Report a mistake

Q22. \t represents

  1. ANew line
  2. BCarriage return
  3. CAlert
  4. DHorizontal tab
Show answer
Answer: D. Horizontal tab
Report a mistake

Q23. getch() function is used to

  1. AClear screen
  2. BRead a single character without echo
  3. CPause only
  4. DPrint a character
Show answer
Answer: B. Read a single character without echo
Report a mistake

Q24. clrscr() is used to

  1. AClear variables
  2. BClose file
  3. CNone
  4. DClear the screen
Show answer
Answer: D. Clear the screen
Report a mistake

Q25. setw manipulator is used for

  1. ASetting precision
  2. BSetting field width
  3. CNone
  4. DSetting fill character
Show answer
Answer: B. Setting field width
Report a mistake

Q26. Operators in C++ are classified as

  1. AUnary, Binary, Ternary
  2. BOnly ternary
  3. COnly unary
  4. DOnly binary
Show answer
Answer: A. Unary, Binary, Ternary
Report a mistake

Q27. Unary operators work on

  1. ATwo operands
  2. BNone
  3. COne operand
  4. DThree operands
Show answer
Answer: C. One operand
Report a mistake

Q28. Binary operators work on

  1. ATwo operands
  2. BOne operand
  3. CNone
  4. DThree operands
Show answer
Answer: A. Two operands
Report a mistake

Q29. The ternary operator in C++ is

  1. A? :
  2. B||
  3. C&&
  4. D++
Show answer
Answer: A. ? :
Report a mistake

Q30. Arithmetic operators include

  1. AOnly + and –
  2. B+, –, *, /, %
  3. COnly * and /
  4. DOnly %
Show answer
Answer: B. +, –, *, /, %
Report a mistake

Q31. Relational operators include

  1. A>, <, >=, <=, ==, !=
  2. BOnly &&
  3. COnly ||
  4. DOnly ==
Show answer
Answer: A. >, <, >=, <=, ==, !=
Report a mistake

Q32. Logical operators include

  1. AOnly ==
  2. BOnly *
  3. COnly +
  4. D&&, ||, !
Show answer
Answer: D. &&, ||, !
Report a mistake

Q33. Assignment operator is

  1. A=
  2. B:=
  3. C==
  4. D+=
Show answer
Answer: A. =
Report a mistake

Q34. Increment operator is

  1. A--
  2. B++
  3. C+=
  4. D*=
Show answer
Answer: B. ++
Report a mistake

Q35. Decrement operator is

  1. A--
  2. B++
  3. C-=
  4. D/=
Show answer
Answer: A. --
Report a mistake

Q36. Precedence of operators determines

  1. AOnly data type
  2. BOnly variable name
  3. COrder of evaluation
  4. DNone
Show answer
Answer: C. Order of evaluation
Report a mistake

Q37. Associativity of operators can be

  1. AOnly right to left
  2. BNone
  3. CLeft to right or Right to left
  4. DOnly left to right
Show answer
Answer: C. Left to right or Right to left
Report a mistake

Q38. An expression is

  1. AOnly a constant
  2. BA combination of operators and operands
  3. COnly a variable
  4. DOnly a function
Show answer
Answer: B. A combination of operators and operands
Report a mistake

Q39. int data type typically occupies

  1. A1 byte
  2. B16 bytes
  3. C2 or 4 bytes
  4. D8 bytes
Show answer
Answer: C. 2 or 4 bytes
Report a mistake

Q40. float data type is used for

  1. AIntegers only
  2. BSingle-precision floating point numbers
  3. CCharacters only
  4. DBoolean only
Show answer
Answer: B. Single-precision floating point numbers
Report a mistake

Q41. double data type provides

  1. ASingle precision
  2. BDouble-precision floating point
  3. CCharacter only
  4. DInteger only
Show answer
Answer: B. Double-precision floating point
Report a mistake

Q42. char data type occupies

  1. A4 bytes
  2. B8 bytes
  3. C1 byte
  4. D2 bytes
Show answer
Answer: C. 1 byte
Report a mistake

Q43. bool data type can hold

  1. AOnly characters
  2. BOnly integers
  3. Ctrue or false
  4. DOnly floats
Show answer
Answer: C. true or false
Report a mistake

Q44. The sizeof operator returns

  1. AType of variable
  2. BSize in bytes of a data type or variable
  3. CAddress of variable
  4. DValue of variable
Show answer
Answer: B. Size in bytes of a data type or variable
Report a mistake

Q45. Implicit type conversion is also called

  1. AType promotion / Coercion
  2. BNone
  3. CManual conversion
  4. DExplicit casting
Show answer
Answer: A. Type promotion / Coercion
Report a mistake

Q46. Explicit type conversion is done using

  1. ANone
  2. BOnly assignment
  3. CCast operator
  4. DOnly operators
Show answer
Answer: C. Cast operator
Report a mistake

Q47. The scope resolution operator is

  1. A::
  2. B->
  3. C:*
  4. D.
Show answer
Answer: A. ::
Report a mistake

Q48. A namespace is used to

  1. AIncrease speed
  2. BNone
  3. CAvoid name conflicts
  4. DDecrease memory
Show answer
Answer: C. Avoid name conflicts
Report a mistake

Q49. The standard namespace in C++ is

  1. Acpp
  2. Bstandard
  3. Cmain
  4. Dstd
Show answer
Answer: D. std
Report a mistake

Q50. using namespace std; allows

  1. AFaster execution
  2. BNone
  3. CLess memory
  4. DUse of cout, cin without std:: prefix
Show answer
Answer: D. Use of cout, cin without std:: prefix
Report a mistake