C++ Programming MCQs

20 practice MCQs on this page Page 2 of 3

Tap an option to check your answer — the correct answer and full explanation appear after you choose.

ProgrammingC++ Programming PPSC FPSC NTSID: PROG-097

What is the output of this C++ code? int x = 3; x = x * x; cout << x;

  1. A3.
  2. B6.
  3. C12.
  4. D9. ✓ Correct answer
ProgrammingC++ Programming PPSC FPSC NTSID: PROG-102

In C++, what is 'cin' used for?

  1. ATo store a number in memory
  2. BTo print output on the screen
  3. CTo read input from the keyboard ✓ Correct answer
  4. DTo end a program
ProgrammingC++ Programming PPSC FPSC NTSID: PROG-107

What is the output of this C++ code? int x = 3; x *= 4; cout << x;

  1. A3
  2. B7
  3. C34
  4. D12 ✓ Correct answer
ProgrammingC++ Programming PPSC FPSC NTSID: PROG-112

In C++, what does the 'cin' command do?

  1. AIt prints output on the screen
  2. BIt stops the program
  3. CIt creates a new file
  4. DIt reads input from the user ✓ Correct answer
ProgrammingC++ Programming PPSC FPSC NTSID: PROG-117

In C++, what does 'endl' do?

  1. AIt reads input from the keyboard.
  2. BIt stops the program.
  3. CIt ends a line and moves to the next line. ✓ Correct answer
  4. DIt saves a file.
ProgrammingC++ Programming BPSCID: BPP-865

Which term is used to write an object to disk?

  1. ATokenization
  2. BSerialization ✓ Correct answer
  3. CDe-serialization
  4. DNone of these
ProgrammingC++ Programming BPSCID: BPP-866

How is dynamically allocated memory de allocated in C++?

  1. AUsing erase()
  2. BAutomatically
  3. CUsing delete ✓ Correct answer
  4. DNone of these
ProgrammingC++ Programming BPSCID: BPP-867

Which catch block should be written first when handling multiple exceptions?

  1. AOrder Irrelevant
  2. BGeneral
  3. CSpecific ✓ Correct answer
  4. DNone of these
ProgrammingC++ Programming BPSCID: BPP-868

Which keyword is used to define an exception block?

  1. AFinally
  2. BCatch
  3. CTry ✓ Correct answer
  4. DThrow
ProgrammingC++ Programming BPSCID: BPP-869

When overriding function which of following should be the same in base and derived class?

  1. AFunction name
  2. BReturn type
  3. CBoth A and B ✓ Correct answer
  4. DParameter list
ProgrammingC++ Programming BPSCID: BPP-870

When overloading functions which of the following must be different?

  1. AFunction name
  2. BReturn type
  3. CBoth A and B
  4. DParameter list ✓ Correct answer
ProgrammingC++ Programming BPSCID: BPP-871

When overloading functions which of the following should be the same?

  1. AFunction name ✓ Correct answer
  2. BReturn type
  3. CBoth A and B
  4. DParameter list
ProgrammingC++ Programming BPSCID: BPP-872

Which feature simplifies complexity by emphasizing high-level design?

  1. APolymorphism
  2. BAbstraction ✓ Correct answer
  3. CInheritance
  4. DAll of them
ProgrammingC++ Programming BPSCID: BPP-873

Feature which enables objects of different classes to respond differently to the same message?

  1. APolymorphism ✓ Correct answer
  2. BAbstraction
  3. CInheritance
  4. DAll of them
ProgrammingC++ Programming BPSCID: BPP-874

Which of the following deals with protecting an object's internal data by controlling access?

  1. APolymorphism
  2. BEncapsulation ✓ Correct answer
  3. CInheritance
  4. DAll of them
ProgrammingC++ Programming STSID: LTP-1817

How many bits of a C++ integer are taken in memory?

  1. A32 bits ✓ Correct answer
  2. B16 bits
  3. C24 bits
  4. DNone of these
ProgrammingC++ Programming BPSCID: BPP-2122

A method can change attributes of an object because objects are passed by

  1. Acopying objects
  2. Bcopy constructors
  3. Creference ✓ Correct answer
  4. Dvalue
ProgrammingC++ Programming BPSCID: BPP-2123

If a class contains multiple methods sharing the same name but with different argument lists, it is

  1. Aover burdened
  2. Bover loaded ✓ Correct answer
  3. Cover used
  4. Dover ridden
ProgrammingC++ Programming BPSCID: BPP-2779

In object-oriented programming, the bundling of data and methods is called:

  1. AEncapsulation ✓ Correct answer
  2. BInheritance
  3. CPolymorphism
  4. DAbstraction
ProgrammingC++ Programming BPSCID: BPP-2780

In object-oriented programming, a class acquiring properties of another class is called:

  1. AInheritance ✓ Correct answer
  2. BPolymorphism
  3. CAbstraction
  4. DEncapsulation

Practice these MCQs interactively