Classes And Objects In C Plus Plus — Part 1 MCQs with Explanations
Practice high-yield Programming & Software Development MCQs on Classes And Objects In C Plus Plus — Part 1 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
Which access specifier allows members of a class to be accessed only by member functions of the same class and its derived classes in C++?
Correct Answer: Option A — protected
Detailed Academic Explanation:
Access specifiers in C++ determine the visibility and accessibility of class members. The protected access specifier allows members of a class to be accessed by: 1. Member functions of the same class 2. Member functions of its derived (child) classes This makes protected different from private , which restricts access only to the class itself, and from public , which allows access from anywhere. Now let’s see why the other options are incorrect: Option B: public — Members are accessible from anywhere in the program , which is more permissive than required by the question. Option C: private — Members are accessible only within the same class , not by derived classes, so this is too restrictive. Option D: friend — friend is not an access specifier; it is a keyword used to allow a specific external function or class to access private or protected members of another class. It doesn’t define a general access level. Conclusion: The protected access specifier is the one that allows class members to be accessed within the same class and its derived classes. Hence, the correct answer is Option A: protected .
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is a class in C++?
Correct Answer: Option C — A blueprint for creating objects
Detailed Academic Explanation:
A blueprint for creating objects is the correct answer to “What is a class in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which keyword is used to create an object of a class in C++?
Correct Answer: Option D — None of the above
Detailed Academic Explanation:
None of the above is the correct answer to “Which keyword is used to create an object of a class in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is an object in C++?
Correct Answer: Option B — An instance of a class
Detailed Academic Explanation:
An instance of a class is the correct answer to “What is an object in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of a constructor in C++?
Correct Answer: Option C — To initialize the object's data members
Detailed Academic Explanation:
To initialize the object's data members is the correct answer to “What is the purpose of a constructor in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which access specifier allows members of a class to be accessed from outside the class in C++?
Correct Answer: Option D — public
Detailed Academic Explanation:
public is the correct answer to “Which access specifier allows members of a class to be accessed from outside the class in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct syntax to define a member function outside the class in C++?
Correct Answer: Option B — returnType className::functionName() {}
Detailed Academic Explanation:
returnType className::functionName() {} is the correct answer to “What is the correct syntax to define a member function outside the class in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the process of combining data and functions into a single unit called in C++?
Correct Answer: Option A — Encapsulation
Detailed Academic Explanation:
Encapsulation is the correct answer to “What is the process of combining data and functions into a single unit called in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What does the 'this' pointer refer to in C++?
Correct Answer: Option D — Pointer to the current object instance
Detailed Academic Explanation:
Pointer to the current object instance is the correct answer to “What does the 'this' pointer refer to in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which keyword is used to declare a member function of a class as constant in C++?
Correct Answer: Option C — const
Detailed Academic Explanation:
const is the correct answer to “Which keyword is used to declare a member function of a class as constant in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'static' keyword in C++ class members?
Correct Answer: Option B — To create a single copy of the member shared by all objects
Detailed Academic Explanation:
To create a single copy of the member shared by all objects is the correct answer to “What is the purpose of the 'static' keyword in C++ class members”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which type of function is used to destroy objects in C++?
Correct Answer: Option C — Destructor
Detailed Academic Explanation:
Destructor is the correct answer to “Which type of function is used to destroy objects in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which operator is used to access members of an object in C++?
Correct Answer: Option A — Dot operator (.)
Detailed Academic Explanation:
Dot operator (.) is the correct answer to “Which operator is used to access members of an object in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the difference between a constructor and a destructor in C++?
Correct Answer: Option C — Constructor is called when an object is created, while destructor is called when an object is destroyed
Detailed Academic Explanation:
Constructor is called when an object is created, while destructor is called when an object is destroyed is the correct answer to “What is the difference between a constructor and a destructor in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the destructor in C++?
Correct Answer: Option B — To release resources acquired by the object
Detailed Academic Explanation:
To release resources acquired by the object is the correct answer to “What is the purpose of the destructor in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which keyword is used to declare a class in C++?
Correct Answer: Option C — class
Detailed Academic Explanation:
class is the correct answer to “Which keyword is used to declare a class in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the static member variable in C++?
Correct Answer: Option D — To maintain common data for all objects
Detailed Academic Explanation:
To maintain common data for all objects is the correct answer to “What is the purpose of the static member variable in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of using friend functions in C++?
Correct Answer: Option C — To allow access to private and protected members of a class from outside the class
Detailed Academic Explanation:
To allow access to private and protected members of a class from outside the class is the correct answer to “What is the purpose of using friend functions in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which access specifier allows members of a class to be accessed only by the derived classes in C++?
Correct Answer: Option B — protected
Detailed Academic Explanation:
protected is the correct answer to “Which access specifier allows members of a class to be accessed only by the derived classes in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the term for a function that is declared inside a class but defined outside of it in C++?
Correct Answer: Option C — Member function
Detailed Academic Explanation:
Member function is the correct answer to “What is the term for a function that is declared inside a class but defined outside of it in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of using constructors in C++?
Correct Answer: Option C — To initialize the object's data members
Detailed Academic Explanation:
To initialize the object's data members is the correct answer to “What is the purpose of using constructors in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which keyword is used to create a copy constructor in C++?
Correct Answer: Option D — None of the above
Detailed Academic Explanation:
None of the above is the correct answer to “Which keyword is used to create a copy constructor in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of a copy constructor in C++?
Correct Answer: Option C — To initialize an object using another object
Detailed Academic Explanation:
To initialize an object using another object is the correct answer to “What is the purpose of a copy constructor in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is a destructor in C++?
Correct Answer: Option A — A special member function that destroys objects
Detailed Academic Explanation:
A special member function that destroys objects is the correct answer to “What is a destructor in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which keyword is used to make a member function constant in C++?
Correct Answer: Option D — const
Detailed Academic Explanation:
const is the correct answer to “Which keyword is used to make a member function constant in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the keyword 'explicit' before a constructor in C++?
Correct Answer: Option B — To prevent implicit conversions during object initialization
Detailed Academic Explanation:
To prevent implicit conversions during object initialization is the correct answer to “What is the purpose of the keyword 'explicit' before a constructor in C++”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <complex> using namespace std; int main () { complex<double> mycomplex (20.0, 2.0); cout << imag(mycomplex) << endl; return 0; }
Correct Answer: Option A — 2
Detailed Academic Explanation:
2 is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <complex> using namespace std; int main () { complex<double> mycomplex (20.0, 2.0); cout << imag(mycomplex) << endl; return 0; }”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How many parameters does a conversion operator may take?
Correct Answer: Option A — 0
Detailed Academic Explanation:
0 is the correct answer to “How many parameters does a conversion operator may take”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; class Integer { int i; public: Integer(int ii) : i(ii) {} const Integer operator+(const Integer& rv) const { cout << "operator+" << endl; return Integer(i + rv.i); } Integer& operator+=(const Integer& rv) { cout << "operator+=" << endl; i += rv.i; return *this; } }; int main() { int i = 1, j = 2, k = 3; k += i + j; Integer ii(1), jj(2), kk(3); kk += ii + jj; }
Correct Answer: Option A — operator+ operator+=
Detailed Academic Explanation:
operator+ operator+= is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; class Integer { int i; public: Integer(int ii) : i(ii) {} const Integer operator+(const Integer& rv) const { cout << "operator+" << endl; return Integer(i + rv.i); } Integer& operator+=(const Integer& rv) { cout << "operator+=" << endl; i += rv.i; return *this; } }; int main() { int i = 1, j = 2, k = 3; k += i + j; Integer ii(1), jj(2), kk(3); kk += ii + jj; }”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following operator cannot be overloaded?
Correct Answer: Option B — ?:
Detailed Academic Explanation:
?: is the correct answer to “Which of the following operator cannot be overloaded”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Pick the correct statement.
Correct Answer: Option B — Macros looks like function calls but they are actually not
Detailed Academic Explanation:
Macros looks like function calls but they are actually not is the correct answer to “Pick the correct statement.”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which is used to define the member of a class externally?
Correct Answer: Option B — ::
Detailed Academic Explanation:
:: is the correct answer to “Which is used to define the member of a class externally”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; ostream & operator<<(ostream & i, int n) { return i; } int main() { cout << 5 << endl; cin.get(); 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; ostream & operator<<(ostream & i, int n) { return i; } int main() { cout << 5 << endl; cin.get(); return 0; }”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class Box{ int capacity; bool operator<(Box b){ return this->capacity < b.capacity ? true : false; } public: Box(){} Box(double capacity){ this->capacity = capacity; } }; int main(int argc, char const *argv[]) { Box b1(10); Box b2 = Box(14); if(b1 < b2){ cout<<"Box 2 has large capacity."; } else{ cout<<"Box 1 has large capacity."; } return 0; }
Correct Answer: Option A — Error
Detailed Academic Explanation:
Error is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class Box{ int capacity; bool operator<(Box b){ return this->capacity < b.capacity ? true : false; } public: Box(){} Box(double capacity){ this->capacity = capacity; } }; int main(int argc, char const *argv[]) { Box b1(10); Box b2 = Box(14); if(b1 < b2){ cout<<"Box 2 has large capacity."; } else{ cout<<"Box 1 has large capacity."; } return 0; }”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which operator a pointer object of a class uses to access its data members and member functions?
Correct Answer: Option B — ->
Detailed Academic Explanation:
-> is the correct answer to “Which operator a pointer object of a class uses to access its data members and member functions”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> using namespace std; int main () { int a, b; a = 10; b = 4; a = b; b = 7; cout << "a:"; cout << a; cout << " b:"; cout << b; return 0; }
Correct Answer: Option A — a:4 b:7
Detailed Academic Explanation:
a:4 b:7 is the correct answer to “What will be the output of the following C++ code? #include <iostream> using namespace std; int main () { int a, b; a = 10; b = 4; a = b; b = 7; cout << "a:"; cout << a; cout << " b:"; cout << b; return 0; }”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main () { std::string str ("Example."); str.back() = '!'; std::cout << str << endl; return 0; }
Correct Answer: Option C — Example!
Detailed Academic Explanation:
Example! is the correct answer to “What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main () { std::string str ("Example."); str.back() = '!'; std::cout << str << endl; return 0; }”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which is the correct example of a unary operator?
Correct Answer: Option C — —
Detailed Academic Explanation:
— is the correct answer to “Which is the correct example of a unary operator”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In case of non-static member functions how many maximum object arguments a binary operator overloaded function can take?
Correct Answer: Option A — 1
Detailed Academic Explanation:
1 is the correct answer to “In case of non-static member functions how many maximum object arguments a binary operator overloaded function can take”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In C Plus Plus
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following operator can be overloaded?
Correct Answer: Option D — ==
Detailed Academic Explanation:
== is the correct answer to “Which of the following operator can be overloaded”. This question is standard in competitive examination syllabi for Classes And Objects In C Plus Plus.
💡Key Conceptual Anchor:Classes And Objects In 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.