Question: 1 -
Which of these following members are not accessed by using direct member access operator?
-
Public
-
Protected
-
Both B & C
-
Private
Answer:
Both B & C
Solution:
Because of the access is given to the private and protected, We can’t access them by using direct member access operator.
Because of the access is given to the private and protected, We can’t access them by using direct member access operator.
Question: 2 -
Which other keywords are also used to declare the class other than class?
-
Struct
-
Both struct & union
-
Union
-
Object
Answer:
Both struct & union
Solution:
Struct and union take the same definition of class but differs in the access techniques.
Struct and union take the same definition of class but differs in the access techniques.
Question: 3 -
How can we make a class abstract?
-
By making at least one member function as pure virtual function.
-
By declaring it abstract using the static keyword.
-
By making all member functions constant
-
By declaring it abstract using the virtual keyword.
Answer:
By making at least one member function as pure virtual function.
Solution:
We can make a class abstract by making at least one member function as pure virtual function.
We can make a class abstract by making at least one member function as pure virtual function.
Question: 4 -
Which of the following is not correct for virtual function in C++ ?
-
Virtual function is defined in base class
-
Virtual function can be static.
-
Must be declared in public section of class
-
Virtual function should be accessed using pointers
Answer:
Virtual function can be static.
Solution:
Virtual function is can’t be static in C++.
Virtual function is can’t be static in C++.
Question: 5 -
How many specifiers are present in access specifiers in class?
-
1
-
4
-
3
-
2
Answer:
3
Solution:
There are three types of access specifiers. They are public, protected and private.
There are three types of access specifiers. They are public, protected and private.