Question 1
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 2
What would be the output of the following code snippet?
#include<iostream>
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 3
Which of the following best supports abstraction in C++?
Pointers
Access specifiers and pure virtual functions
Constructors
Inheritance
Question 4
Which access specifier is commonly used to hide data in abstraction?
Public
Private
Protected
Any of these
Question 5
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
There are 5 questions to complete.