Object Oriented Programming MCQs

Page No. 21

Which among the following is correct to call a private member from outside the class?


aobject.memberfunction( parameters );


bobject->memberfunction( parameters );


c object->memberfunction( parameteres); or object.memberfunction( parameters );


dNot possible


View Answer Not possible

If a function has to be called only by using other member functions of the class, what should be the access specifier used for that function?


aPrivate


bProtected


cPublic


dDefault


View Answer Private

If a class have default constructor defined in private access, and one parameter constructor in protected mode, how will it be possible to create instance of object?


aDefine a constructor in public access with different signature


bDirectly create the object in the subclass


cDirectly create the object in main() function


dNot possible



. Protected access is same as default access that is given implicitly in java if no specifier is mentioned.


aTrue


bFalse


cA & B


d None of these


View Answer False

Which among the following can use protected access specifier?


aMembers which may be used in other packages


bMembers which have to be secure and should be used by other packages/subclass


cMembers which have to be accessed from anywhere in the program


dMembers which have to be as secure as private but can be used by main() function



If protected members are to be accessed from outside the class then__________


aMembers must be inherited publicly in subclass


bMembers must accessed using class pointers


cMembers must be accessed as usual


dMembers must be made public



If protected inheritance is used then _____


aPublic members become public in subclass


bProtected members become public in subclass


cProtected members become protected in subclass


dProtected and Public members become protected in subclass



If all the members are defined in protected specifier then? (Constructors not considered)


aInstance of class can’t be created


bInstance of class can be created anywhere


cInstance of class can be created only in subclasses


dInstance of class can be created only in main() function



Protected members differ from default members as _______


aProtected members can be accessed outside package using inheritance, but default can’t


bDefault members can be accessed outside package using inheritance, but protected can’t


cProtected members are allowed for inheritance but Default members are not allowed


dBoth are same



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?


aThe sub class should inherit the parent class privately


bThe sub class should inherit the parent class as protected


cThe sub class should inherit the parent class as public


dThe sub class can use any access modifier



Goto Page No.

Page 21 of 93

Alphabetical MCQs Categories

Here below You find all kind of categories of MCQs in alphabetical order.


"Comprehensive Collection of MCQs: Alphabetically Organized by Subject"

"Discover an extensive collection of multiple-choice questions (MCQs) neatly categorized by subject from A to Z. This resource is designed for anyone eager to explore various topics in a straightforward and organized manner. Whether you're a student preparing for exams, an educator seeking supplementary materials, or simply curious about different subjects, this compilation offers a convenient way to learn and assess your knowledge. With questions arranged alphabetically, navigation is effortless, allowing you to delve into subjects of interest at your own pace. Engage, learn, and expand your understanding with this accessible and comprehensive repository of MCQs!"


BolPakistan

bolpakistan.com.pk includes Job Mcqs and Pak Mcqs is the Top Largest Mcqs Forum in World, in which you can read Mcqs of All Subjects, PPSC test preparation, FPSC, NTS and PPSC PAST PAPERS, PPSC PAST MCQS. A Collection of Repeated MCQs for JOBs seekers.

Copyright © 2024, Designed & Developed by BolPakistan