C++ MCQ’s

C++ MCQ’s Home Page

C++ Basic 1
C++ Basic 2
C++ Basic 3
C++ Basic 4
C++ Basic 5
C++ OOPs Concepts 1
C++ OOPs Concepts 2
C++ OOPs Concepts 3
C++ OOPs Concepts 4
C++ OOPs Concepts 5

 

Cpp Language MCQ’S | OOPs Concepts Set 4

1.
What happens if the following code is compiled on both C and C++?

#include<stdio.h>
struct STRUCT
{
private:
int a;
};
int main()
{
printf(“%d\n”, (int)sizeof(struct STRUCT));
return 0;
}

a) The program runs fine and both prints output “HELLO THIS IS STRUCTURE”
b) The program gives an error in case of C but runs perfectly in case of C++
c) The program gives an error in case of C++ but runs perfectly in case of C
d) The program gives an error in case of both C and C++

 

2.
Which of the following is correct about this pointer in C++?

a) this pointer is passed as a hidden argument in all the functions of a class
b) this pointer is passed as a hidden argument in all non-static functions of a class
c) this pointer is passed as a hidden argument in all static functions of a class
d) this pointer is passed as a hidden argument in all static variables of a class

 

3.
Which of the following operator is used with this pointer to access members of a class?

a) .
b) !
c) ->
d) ~

 

4.
Why this pointer is used?

a) To access the members of a class which have the same name as local variables in that scope
b) To access all the data stored under that class
c) To access objects of other class
d) To access objects of other variables

 

5.
Wrapping data and its related functionality into a single entity is known as _____________

a) Abstraction
b) Encapsulation
c) Polymorphism
d) Modularity


 

Visitor Counter

0142245