Ques 1. What is the output of the following assuming that the size of int is 4 bytes.
D) Compile error
Answer : B
Only the class member variables constitutes as the size of the class or its object.So in this case we have to void and one int value so total size of class will be 0 + 0 + 4.(consider int to be 4 byte).
Ques 2. What is the output of the following
C) Compile error
D) Runtime error
Answer : B
when we assign array ‘a’ to pointer ‘p’, it will hold the base address of the array. We can access array using ‘p’ just like with ‘a’
Ques 3. What is the output of the following
Answer : C
*a refers to 10 and adding a 1 to it gives 11.
Ques 4. What is the output of the following
Answer : D
We are using friend function because we want to print the value of box width. Which is a private member function of a class and we can not access the private member outside the class.
setWidth(10.0) set width to 10 and printWidth( box ) print (width * 2) i.e 20.
Ques 5. What is the output of the following
C) Runtime error
D) None of the mentioned
Answer : A
Explanation : class or structure ‘c’ inheriting class ‘a’ as well as class ‘b’. When we create an object p of class c, both a and b are automatically inherited means we can access the attributes of class a and b.
So, p->value will be set to 0 as given in the question and then print inherited and exit from the code.
This article is contributed by Rishabh jain. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.