Question

Consider relevant issues when determining whether to use protected or private members in a base class....

Consider relevant issues when determining whether to use protected or private members in a base class. Are there any risks involved with using the protected member access specifier instead of the private member access specifier?

Homework Answers

Answer #1

Private: if you declare any variable/method as Private than you can't access the variable/method outside of that class. So strictly variable/method is available only with in the class.

Protected: if you declare any variable/method as Protected than we can access variable/method with in the class as well and in all its child classes

So if you want variable/method should available with in the class than you should use Private. if you want share the variable/method to its child classes than you should use Protected

There is no risk as it is available only for its child classes

Note : If you like my answer please rate and help me it is very Imp for me

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Consider the following code snippet: // A.java public class A { private String name; protected A(String...
Consider the following code snippet: // A.java public class A { private String name; protected A(String n) { name = n; } } // B.java public class B extends A { public B(String n) { super(n); } public String toString() { return name; } } What's wrong with the above code? Select all that apply. This code will encounter an access error at runtime. This code will not compile, because A's constructor is not declared public. This code will not...
Problem ( Foraging in the Forest) Consider these rules when determining whether a mushroom is poisonous:...
Problem ( Foraging in the Forest) Consider these rules when determining whether a mushroom is poisonous: 1. If a mushroom is poisonous, then it is orange. 2. If a mushroom is poisonous, then it has gills. 3. If a mushroom is not poisonous, then it has pores. 4. If a mushroom is not poisonous, then it is found growing from the trunk of a living hardwood tree. 5. If a mushroom is bioluminescent (glows in the dark), then it is...
Suppose that a test for determining whether a person has been infected with COVID-19 has a...
Suppose that a test for determining whether a person has been infected with COVID-19 has a 20% rate of false positives (i.e. in 20% of applications, the test falsely indicates that a person has been infected with COVID-19 when they actually have not). Now, consider the likelihood that when 100 healthy people are tested, the test falsely indicates that between 10 and 30 of them are infected. c. Before you use the normal approximation to calculate P(10 ≤ x≤ 30),...
^Kori^: 21. Which of the following is not relevant in determining whether an activity is profit...
^Kori^: 21. Which of the following is not relevant in determining whether an activity is profit seeking or a hobby?     A.   Whether the activity is enjoyed by the taxpayer.     B.   The expertise of the taxpayers and time and effort expended.     C.   The relationship of profits earned and losses incurred.     D.   All of these are relevant factors. ^Kori^: 22. Barbara is in the business of dairy farming. During the year, one of her barns was completely destroyed...
C++ 5a)We have the following class: class Banana { private:      string s;      int y;...
C++ 5a)We have the following class: class Banana { private:      string s;      int y; public: bool theMemberFunc (string); void setterForS(string); // setter for s string getterForS(); // getter for s }; Instantiate a static object of Banana named co. a)int Banana; b)co.Banana = new; c)Banana = new class; d)Banana co; 5b)Code a call to function aNonclassFunction passing co. a)aNonclassFunction (co); b)aNonclassFunction (* co); c)aNonclassFunction (aGoodClass.co); d)aNonclassFunction (aGoodClass); 5c)Code the function definition for aNonclassFunction, picking up co. aNonclassFunction has...
Need to get the following output by Editing ChekingAccount.h ,ChekingAccount.cpp CheckingAccount Derived class CheckingAccount that inherits...
Need to get the following output by Editing ChekingAccount.h ,ChekingAccount.cpp CheckingAccount Derived class CheckingAccount that inherits from base class Account and include an additional data member of type double that represents the fee charged per transaction (transactionFee). Write Checking- Account’s constructor that receives the initial balance, as well as a parameter indicating a transaction fee amount. If transaction fee is less than zero, the transactionFee will be set to zero. Write the chargeFee member function that updates the balance by...
java CLASS DESIGN GUIDELINES 1. Cohesion • [✓] A class should describe a single entity, and...
java CLASS DESIGN GUIDELINES 1. Cohesion • [✓] A class should describe a single entity, and all the class operations should logically fit together to support a coherent purpose. • [✓] A single entity with many responsibilities can be broken into several classes to separate the responsibilities. 2. Consistency • [✓] Follow standard Java programming style and naming conventions. Choose informative names for classes, data fields, and methods. A popular style is to place the data declaration before the constructor...
What costs are relevant when determining how many pizzas a month Zume Pizza must sell to...
What costs are relevant when determining how many pizzas a month Zume Pizza must sell to break even? Zume Pizza uses a combination of robots, artificial intelligence (AI), and GPS in its food trucks to deliver pizzas to customers’ houses just as the pizza is finished baking. Pizzas are actually prepared and baked in the Zume pizza truck by an employee assisted by robots. Zume Pizza started operations in April 2016 and is currently selling about 250 pizzas per day....
**[70 pts]** You will be writing a (rather primitive) online store simulator. It will have these...
**[70 pts]** You will be writing a (rather primitive) online store simulator. It will have these classes: Product, Customer, and Store. All data members of each class should be marked as **private** (a leading underscore in the name). Since they're private, if you need to access them from outside the class, you should do so via get or set methods. Any get or set methods should be named per the usual convention ("get_" or "set_" followed by the name of...
BACKGROUND AND FACTS The European Communities requested a WTO panel to decide whether U.S. Sections 301-310...
BACKGROUND AND FACTS The European Communities requested a WTO panel to decide whether U.S. Sections 301-310 [the Act] violated GATT dispute settlement procedures. The Act permits the USTR to investigate possible violations of GATT or other international trade agreements, to negotiate a settlement of the dispute, and to request a WTO dispute settlement panel if necessary. The Act also permits the USTR to impose retaliatory tariffs or other trade sanctions either unilaterally or if authorized by theWTODispute Settlement Body. The...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT