Introduction To C Plus Plus — Part 2 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Introduction To C Plus Plus — Part 2 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/40 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct syntax to define a class named 'Rectangle' with private member variables 'length' and 'width' in C++?
Correct Answer: Option D — class Rectangle { private: int length, width; }
Detailed Academic Explanation:
class Rectangle { private: int length, width; } is the correct answer to “What is the correct syntax to define a class named 'Rectangle' with private member variables 'length' and 'width' in C++”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'break' statement in a loop in C++?
Correct Answer: Option C — Exit the loop
Detailed Academic Explanation:
Exit the loop is the correct answer to “What is the purpose of the 'break' statement in a loop in C++”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct way to define a constant named 'PI' with a value of 3.14159 in C++?
Correct Answer: Option B — const double PI = 3.14159
Detailed Academic Explanation:
const double PI = 3.14159 is the correct answer to “What is the correct way to define a constant named 'PI' with a value of 3.14159 in C++”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the output of the following code: cout << (10 % 3); in C++?
Correct Answer: Option C — 1
Detailed Academic Explanation:
1 is the correct answer to “What is the output of the following code: cout << (10 % 3); in C++”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following program in both C and C++? #include<stdio.h> int main(int argc, char const *argv[]) { printf("%d\n", (int)sizeof('a')); return 0; }
Correct Answer: Option B — Output in C is 4 and in C++ is 1
Detailed Academic Explanation:
Output in C is 4 and in C++ is 1 is the correct answer to “What will be the output of the following program in both C and C++? #include<stdio.h> int main(int argc, char const *argv[]) { printf("%d\n", (int)sizeof('a')); return 0; }”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What happens if a class does not have a name?
Correct Answer: Option B — It will not have a destructor
Detailed Academic Explanation:
It will not have a destructor is the correct answer to “What happens if a class does not have a name”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following escape sequence represents carriage return?
Correct Answer: Option A — \r
Detailed Academic Explanation:
\r is the correct answer to “Which of the following escape sequence represents carriage return”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What are the formal parameters in C++?
Correct Answer: Option B — Parameters which are used in the definition of the function
Detailed Academic Explanation:
Parameters which are used in the definition of the function is the correct answer to “What are the formal parameters in C++”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is a static polymorphism mechanism?
Correct Answer: Option D — All of the mentioned
Detailed Academic Explanation:
All of the mentioned is the correct answer to “Which of the following is a static polymorphism mechanism”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What if we define the below structure in C and C++?
Correct Answer: Option A — Error in C but not in C++
Detailed Academic Explanation:
Error in C but not in C++ is the correct answer to “What if we define the below structure in C and C++”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is true? I. All operators in C++ can be overloaded. II. The basic meaning of an operator can be changed.
Correct Answer: Option D — Neither I nor II
Detailed Academic Explanation:
Neither I nor II is the correct answer to “Which of the following is true? I. All operators in C++ can be overloaded. II. The basic meaning of an operator can be changed.”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is std in C++?
Correct Answer: Option B — std is a standard namespace in C++
Detailed Academic Explanation:
std is a standard namespace in C++ is the correct answer to “What is std in C++”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is dynamic binding?
Correct Answer: Option A — The process of linking the actual code with a procedural call during run-time
Detailed Academic Explanation:
The process of linking the actual code with a procedural call during run-time is the correct answer to “What is dynamic binding”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What happens if the following line is executed in C and C++? const int a;
Correct Answer: Option D — Error in C++ and successful execution in C
Detailed Academic Explanation:
Error in C++ and successful execution in C is the correct answer to “What happens if the following line is executed in C and C++? const int a;”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What happens if we run the following code in both C and C++? #include<stdio.h> struct STRUCT { int a = 5; int func() { printf("%d\n", a); } }; int main() { struct STRUCT s; s.func(); return 0; }
Correct Answer: Option B — The program gives an error in case of C but runs perfectly in case of C++
Detailed Academic Explanation:
The program gives an error in case of C but runs perfectly in case of C++ is the correct answer to “What happens if we run the following code in both C and C++? #include<stdio.h> struct STRUCT { int a = 5; int func() { printf("%d\n", a); } }; int main() { struct STRUCT s; s.func(); return 0; }”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include<iostream> using namespace std; class A { ~A(){ cout<<"Destructor called\n"; } }; int main() { A *a1 = new A(); A *a2 = new A(); return 0; }
Correct Answer: Option D — Nothing is printed
Detailed Academic Explanation:
Nothing is printed is the correct answer to “What will be the output of the following C++ code? #include<iostream> using namespace std; class A { ~A(){ cout<<"Destructor called\n"; } }; int main() { A *a1 = new A(); A *a2 = new A(); return 0; }”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is called extraction/get from operator?
Correct Answer: Option B — >>
Detailed Academic Explanation:
>> is the correct answer to “Which of the following is called extraction/get from operator”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is called address operator?
Correct Answer: Option B — &
Detailed Academic Explanation:
& is the correct answer to “Which of the following is called address operator”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is name mangling in C++?
Correct Answer: Option A — The process of adding more information to a function name so that it can be distinguished from other functions by the compiler
Detailed Academic Explanation:
The process of adding more information to a function name so that it can be distinguished from other functions by the compiler is the correct answer to “What is name mangling in C++”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the size of a boolean variable in C++?
Correct Answer: Option A — 1 bit
Detailed Academic Explanation:
1 bit is the correct answer to “What is the size of a boolean variable in C++”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the size of a character literal in C and C++?
Correct Answer: Option A — 4 and 1
Detailed Academic Explanation:
4 and 1 is the correct answer to “What is the size of a character literal in C and C++”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is correct?
Correct Answer: Option A — struct cannot have member function in C but it can in C++
Detailed Academic Explanation:
struct cannot have member function in C but it can in C++ is the correct answer to “Which of the following is correct”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include<iostream> using namespace std; class A { ~A(){ cout<<"Destructor called\n"; } }; int main() { A a; return 0; }
Correct Answer: Option C — Error
Detailed Academic Explanation:
Error is the correct answer to “What will be the output of the following C++ code? #include<iostream> using namespace std; class A { ~A(){ cout<<"Destructor called\n"; } }; int main() { A a; return 0; }”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Why this pointer is used?
Correct Answer: Option A — To access the members of a class which have the same name as local variables in that scope
Detailed Academic Explanation:
To access the members of a class which have the same name as local variables in that scope is the correct answer to “Why this pointer is used”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is correct about static variables?
Correct Answer: Option C — Static data members functions can access only static data members
Detailed Academic Explanation:
Static data members functions can access only static data members is the correct answer to “Which of the following is correct about static variables”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following syntax can be used to use a member of a namespace without including that namespace?
Correct Answer: Option A — namespace::member
Detailed Academic Explanation:
namespace::member is the correct answer to “Which of the following syntax can be used to use a member of a namespace without including that namespace”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Who created C++?
Correct Answer: Option A — Bjarne Stroustrup
Detailed Academic Explanation:
Bjarne Stroustrup is the correct answer to “Who created C++”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is correct about static polymorphism?
Correct Answer: Option A — In static polymorphism, the conflict between the function call is resolved during the compile time
Detailed Academic Explanation:
In static polymorphism, the conflict between the function call is resolved during the compile time is the correct answer to “Which of the following is correct about static polymorphism”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is the scope resolution operator?
Correct Answer: Option C — ::
Detailed Academic Explanation:
:: is the correct answer to “Which of the following is the scope resolution operator”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What happens if the following program is executed in C and C++? #include <stdio.h> void main() { printf("Hello World"); }
Correct Answer: Option D — Error in C++ and successful execution in C
Detailed Academic Explanation:
Error in C++ and successful execution in C is the correct answer to “What happens if the following program is executed in C and C++? #include <stdio.h> void main() { printf("Hello World"); }”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is an entry-controlled loop?
Correct Answer: Option D — both while and for
Detailed Academic Explanation:
both while and for is the correct answer to “Which of the following is an entry-controlled loop”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> int const s=9; int main() { std::cout << s; return 0; }
Correct Answer: Option A — 9
Detailed Academic Explanation:
9 is the correct answer to “What will be the output of the following C++ code? #include <iostream> int const s=9; int main() { std::cout << s; return 0; }”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which concept is used to implement late binding?
Correct Answer: Option A — Virtual functions
Detailed Academic Explanation:
Virtual functions is the correct answer to “Which concept is used to implement late binding”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following cannot be used with the virtual keyword?
Correct Answer: Option C — Constructors
Detailed Academic Explanation:
Constructors is the correct answer to “Which of the following cannot be used with the virtual keyword”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What happens if the following program is executed in C and C++? #include <stdio.h> int main(void) { int new = 5; printf("%d", new); }
Correct Answer: Option D — Error in C++ and successful execution in C
Detailed Academic Explanation:
Error in C++ and successful execution in C is the correct answer to “What happens if the following program is executed in C and C++? #include <stdio.h> int main(void) { int new = 5; printf("%d", new); }”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is an exit-controlled loop?
Correct Answer: Option C — do-while
Detailed Academic Explanation:
do-while is the correct answer to “Which of the following is an exit-controlled loop”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; class Test { static int x; public: Test() { x++; } static int getX() {return x;} }; int Test::x = 0; int main() { cout << Test::getX() << " "; Test t[5]; cout << Test::getX(); }
Correct Answer: Option C — 0 5
Detailed Academic Explanation:
0 5 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; class Test { static int x; public: Test() { x++; } static int getX() {return x;} }; int Test::x = 0; int main() { cout << Test::getX() << " "; Test t[5]; cout << Test::getX(); }”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What happens if the following program is executed in C and C++? #include<stdio.h> int main() { foo(); } int foo() { printf("Hello"); return 0; }
Correct Answer: Option C — Error in C++ but Warning in C
Detailed Academic Explanation:
Error in C++ but Warning in C is the correct answer to “What happens if the following program is executed in C and C++? #include<stdio.h> int main() { foo(); } int foo() { printf("Hello"); return 0; }”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is C++ equivalent for scanf()?
Correct Answer: Option A — cin
Detailed Academic Explanation:
cin is the correct answer to “Which of the following is C++ equivalent for scanf()”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include<iostream> using namespace std; int x = 1; int main() { int x = 2; { int x = 3; cout << ::x << endl; } return 0; }
Correct Answer: Option A — 1
Detailed Academic Explanation:
1 is the correct answer to “What will be the output of the following C++ code? #include<iostream> using namespace std; int x = 1; int main() { int x = 2; { int x = 3; cout << ::x << endl; } return 0; }”. This question is standard in competitive examination syllabi for Introduction To C Plus Plus.
💡Key Conceptual Anchor:Introduction To C Plus Plus
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.