Question 1
How do pure virtual functions help achieve abstraction in C++?
Do not help in any way
Allow the class to show only the interface, not the implementation
Help in combining data and functions together
Abstraction is not applicable to classes
Question 2
.Which of the following best describes the concept of abstraction in object-oriented programming?
Restricting access to certain class members from outside the class
Representing essential features without including background details
Combining data and methods into a single unit
Allowing multiple classes to inherit from a single superclass
Question 3
What is the primary purpose of abstraction in OOP?
Treating objects of different classes uniformly
Simplifying complex systems by focusing on essential characteristics
Defining attributes and behaviors of objects
Protecting data using access modifiers
Question 4
Which of the following is NOT true about interfaces?
Can contain default methods
Can contain constructors
Can be implemented by multiple classes
Can contain static methods
Question 5
Which of the following best describes abstraction?
Hiding implementation details and showing only relevant information to the users.
Binding both data members and member functions into a single unit.
Accessing data members and member functions of one class by other
All of the above
Question 6
What would be the output of the following code snippet?
#include
Using namespace std;
class implementAbstraction{
private:
int a,b;
void set(int x,int y)
{
a=x;
b=y;
}
void display()
{
cout<<”a=”<<a<<endl;
cout<<”b=”<<b<<endl;
}
};
int main()
{
implementAbstraction obj;
obj.set(10,20);
obj.display();
return 0;
}
a = 10, b = 20
a = 20, b = 10
Compilation Error
Runtime Error
Question 7
Which of the following best supports abstraction in C++?
Pointers
Access specifiers and pure virtual functions
Constructors
Inheritance
Question 8
Which access specifier is commonly used to hide data in abstraction?
Public
Private
Protected
Any of these
Question 9
What is the major difference in abstraction and encapsulation?
Abstraction hides implementation encapsulation binds data and function together.
Abstraction uses private members and encapsulation uses public members.
Encapsulation hides logic and abstraction binds data.
There is no difference
Question 10
What is Abstraction?
Hiding complexity, showing only essential parts
Creating multiple objects
Inheriting properties
Encapsulating data
There are 10 questions to complete.