adplus-dvertising

Welcome to the Access Specifiers MCQs Page

Dive deep into the fascinating world of Access Specifiers with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Access Specifiers, a crucial aspect of Object Oriented Programming. In this section, you will encounter a diverse range of MCQs that cover various aspects of Access Specifiers, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Object Oriented Programming.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Access Specifiers. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Object Oriented Programming.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Access Specifiers. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Access Specifiers MCQs | Page 4 of 6

Explore more Topics under Object Oriented Programming

Q31.
If the protected members are to be made accessible only to the nearest subclass and no further subclasses, which access specifier should be used in inheritance?
Discuss
Answer: (a).The sub class should inherit the parent class privately
Q32.
What will be the output of following code (all header files and required things are included)?
class A
{
 int marks;
 protected : A(int x)
 { 
  marks=x; 
 }
 public : A()
 { 
  marks=100; 
 }
}
class B
{
 A a;
 A b=100;
};
main()
{
 A a, b=100;
 B c;
}
Discuss
Answer: (c).Program gives compile time error
Q33.
Which among the following is true for the given code below.
class A
{
 protected : int marks;
 public : 
 A()
 { 
  marks=100; 
 }
 disp()
 { 
  cout<<”marks=”<<marks; 
 }
};
class B: protected A
{
};
B b;
b.disp();
Discuss
Answer: (a).Object b can’t access disp() function
Discuss
Answer: (a).Protected members can be accessed outside package using inheritance, but default can’t
Discuss
Answer: (b).Instance of class can be created anywhere
Q36.
Which among the following is correct for the code given.
class A
{
    private: int marks;
    A()
    { 
    }
    Public : disp()
    { 
          cout<< marks; 
     }
};
class B: public A
{
}
B b;
Discuss
Answer: (a).Instance of B will not be created
Discuss
Answer: (d).Protected and Public members become protected in subclass
Discuss
Answer: (d).Members must be made public
Discuss
Answer: (b).Members which have to be secure and should be used by other packages/subclass
Q40.
Protected access is same as default access that is given implicitly in java if no specifier is mentioned.
Discuss
Answer: (b).False
Page 4 of 6

Suggested Topics

Are you eager to expand your knowledge beyond Object Oriented Programming? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!