C++: Classes And Objects Questions 2

Q.6
A C+++ class contains…

a. Member Functions
b. Data Members
c. Both a and b
d. Customize main () function

Q.7
Where a class member function can be defined?

a. Inside the class definition
b. Outside of the class definition
c. Both a and b
d. Don’t know

Q.8
Can we declare a member function private?

a. Yes
b. No

Q.9
What will be the output of this program?

#include <iostream>
using namespace std;
//Empty class
class test
{
};

int main()
{
test testObj;
cout<<“size =”<<sizeof(testObj);
return 0;
}

a. Error
b. size =Garbage
c. size =1

Q.10
Which is correct sentence regarding structure and class in c?

a. Both are same in C++.
b. By default structure’s members are public and class’s members are private.
c. Structure does not support function declaration within its declaration while class supports.
d. Both b and c.