Skip to main content

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
Question 1 of 40
★ 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++?

Question 2 of 40
★ FPSC ★ PPSC

What is a class in C++?

Question 3 of 40
★ FPSC ★ PPSC

Which keyword is used to create an object of a class in C++?

Question 4 of 40
★ FPSC ★ PPSC

What is an object in C++?

Question 5 of 40
★ FPSC ★ PPSC

What is the purpose of a constructor in C++?

Question 6 of 40
★ FPSC ★ PPSC

Which access specifier allows members of a class to be accessed from outside the class in C++?

Question 7 of 40
★ FPSC ★ PPSC

What is the correct syntax to define a member function outside the class in C++?

Question 8 of 40
★ FPSC ★ PPSC

What is the process of combining data and functions into a single unit called in C++?

Question 9 of 40
★ FPSC ★ PPSC

What does the 'this' pointer refer to in C++?

Question 10 of 40
★ FPSC ★ PPSC

Which keyword is used to declare a member function of a class as constant in C++?

Question 11 of 40
★ FPSC ★ PPSC

What is the purpose of the 'static' keyword in C++ class members?

Question 12 of 40
★ FPSC ★ PPSC

Which type of function is used to destroy objects in C++?

Question 13 of 40
★ FPSC ★ PPSC

Which operator is used to access members of an object in C++?

Question 14 of 40
★ FPSC ★ PPSC

What is the difference between a constructor and a destructor in C++?

Question 15 of 40
★ FPSC ★ PPSC

What is the purpose of the destructor in C++?

Question 16 of 40
★ FPSC ★ PPSC

Which keyword is used to declare a class in C++?

Question 17 of 40
★ FPSC ★ PPSC

What is the purpose of the static member variable in C++?

Question 18 of 40
★ FPSC ★ PPSC

What is the purpose of using friend functions in C++?

Question 19 of 40
★ FPSC ★ PPSC

Which access specifier allows members of a class to be accessed only by the derived classes in C++?

Question 20 of 40
★ FPSC ★ PPSC

What is the term for a function that is declared inside a class but defined outside of it in C++?

Question 21 of 40
★ FPSC ★ PPSC

What is the purpose of using constructors in C++?

Question 22 of 40
★ FPSC ★ PPSC

Which keyword is used to create a copy constructor in C++?

Question 23 of 40
★ FPSC ★ PPSC

What is the purpose of a copy constructor in C++?

Question 24 of 40
★ FPSC ★ PPSC

What is a destructor in C++?

Question 25 of 40
★ FPSC ★ PPSC

Which keyword is used to make a member function constant in C++?

Question 26 of 40
★ FPSC ★ PPSC

What is the purpose of the keyword 'explicit' before a constructor in C++?

Question 27 of 40
★ 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; }

Question 28 of 40
★ FPSC ★ PPSC

How many parameters does a conversion operator may take?

Question 29 of 40
★ 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; }

Question 30 of 40
★ FPSC ★ PPSC

Which of the following operator cannot be overloaded?

Question 31 of 40
★ FPSC ★ PPSC

Pick the correct statement.

Question 32 of 40
★ FPSC ★ PPSC

Which is used to define the member of a class externally?

Question 33 of 40
★ 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; }

Question 34 of 40
★ 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; }

Question 35 of 40
★ FPSC ★ PPSC

Which operator a pointer object of a class uses to access its data members and member functions?

Question 36 of 40
★ 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; }

Question 37 of 40
★ 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; }

Question 38 of 40
★ FPSC ★ PPSC

Which is the correct example of a unary operator?

Question 39 of 40
★ FPSC ★ PPSC

In case of non-static member functions how many maximum object arguments a binary operator overloaded function can take?

Question 40 of 40
★ FPSC ★ PPSC

Which of the following operator can be overloaded?

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 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.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →