Question

In: Computer Science

Give both an advantage and disadvantage of both private and public visibility as used in the...

Give both an advantage and disadvantage of both private and public visibility as used in the design of an object (list four items)

Solutions

Expert Solution

Before starting to give your answer let's find out what inheritance and encapsulation is because this will help you to understand well about private and public class in oop.

Inheritance is a mechanism where you can Derive a class from another class

Encapsulation means the process to bind both the data and the function.

Now let's start with the question about differences of private and public visibility,remember the thing that only variable and methods and class can be defined as private and public

PUBLIC AND PRIVATE

Start with the word public means anyone can access where as private means that only members of the same class are allowed to access it .

1.

private - least access, best encapsulation

public - full access, no encapsulation

2.

Private means better security in terms of accessing the objects where as public means less security to access the objects.

3.

Methods that serve as the inner workings of your class and don’t output or display information here we use private

4.

In private methods that don’t add to the interface and do not collaborate with other classes can be used where as if we want collaboration with another class use public or protected

Kindly voteup if found useful


Related Solutions

1.Give an advantage and a disadvantage of a parallel combination. Give an example. 2.Give a few...
1.Give an advantage and a disadvantage of a parallel combination. Give an example. 2.Give a few essential features of an ordinary cell. 3.How should two identical batteries be connected in order to obtain the maximum EMF from the combination, should it be in series or parallel? Why? ? 4.How does the resistance of a conductor affected by its length and diameter?
How are forwards and/or futures used and what is an advantage and disadvantage of their use...
How are forwards and/or futures used and what is an advantage and disadvantage of their use from a company perspective. From an investor perspective? Discuss the importance of Forwards and Futures as they pertains to a MNC giving an example of its use. Do you support their use and why? Try to provide a real example.
2 Give an example of a healthcare circumstance in which both public and private regulation are...
2 Give an example of a healthcare circumstance in which both public and private regulation are present. Which serves the consumers better and why? 3 Assuming you are the manager of a company, how could you use behavioral economics to increase the number of insured employees in your firm?
How flexible premiums can be both an advantage and a disadvantage of Universal Life Insurance?
How flexible premiums can be both an advantage and a disadvantage of Universal Life Insurance?
One advantage and one disadvantage of minimum wage with respect to poverty and inequality, and give...
One advantage and one disadvantage of minimum wage with respect to poverty and inequality, and give one example of each one?
Give one advantage and one disadvantage of using a plasma excitation source (as oppaosed to a...
Give one advantage and one disadvantage of using a plasma excitation source (as oppaosed to a flame) for emission spectroscopy.
give one advantage and one disadvantage of using 9.0 of alumina in your column instead of...
give one advantage and one disadvantage of using 9.0 of alumina in your column instead of 4.5 g as you did during the column chromatography experiment in lab.
What are three general approaches to obtaining an expert system? Give one advantage and one disadvantage...
What are three general approaches to obtaining an expert system? Give one advantage and one disadvantage for each approach.
what the advantage and disadvantage of cybersecurity in the ministry of health ?
what the advantage and disadvantage of cybersecurity in the ministry of health ?
Name an advantage and a disadvantage of giving a medication orally ?
Name an advantage and a disadvantage of giving a medication orally ?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT