Question

In: Computer Science

risks involved with using the protected member access specifier instead of the private member access specifier?

risks involved with using the protected member access specifier instead of the private member access specifier?

Solutions

Expert Solution

Explanation:

A private member access specifier is only accessible within the same class as it is declared.

A protected member access specifier is accessible within all classes in the same package and within sub classes in other packages.

Risks involved with using the protected member access specifier instead of the private member access specifier:

  1. A protected member access specifier is "visible" to sub classes and protected members can be seen by all sub classes and all classes that are in the same package. This makes it much harder to later change the field because more classes might be referencing it.
  2. A sub class can use them and may break if you happen to change protected members due to evolution of your class or change in requirements.
  3. A sub class can extend the protected members and make it exposed to the outside (public) world
  4. No such risk in case of private members as private members can only be seen by its own class (and inner classes).

The following table depicts the

  Class
  Package
  Subclass

(same pkg)

  Subclass

(diff pkg)

  World
  protected
+ + + +
  private
+
   + : accessible         blank : not accessible

Related Solutions

Granval is concerned about the risks involved in launching a new business, especially the financial risks....
Granval is concerned about the risks involved in launching a new business, especially the financial risks. If he chooses the sole proprietorship form of ownership, his liability is ________. Group of answer choices a) shared with his investors b) limited to the amount of his taxes c) shared with his creditors d) unlimited is an important part of researching a firm's feasibility. Group of answer choices a) Researching the legal business forms b) Pinpointing potential competitive advantages c) Identifying potential...
As a member of the Eurozone, Greece was/is unable to conduct it’s own monetary policy. Instead,...
As a member of the Eurozone, Greece was/is unable to conduct it’s own monetary policy. Instead, Eurozone monetary policy is set by the European Central Bank in Frankfurt. Suppose that Greece is facing a recession and wants to boost output. 1. What type of government policy would you suggest to boost output? Provide an IS-LM graph with a clear explanation of what you are suggesting. 2. How would the government fund such a policy? 3. What are some of the...
Walt, age 62, worked as an assembler for a private manufacturer and is a member of...
Walt, age 62, worked as an assembler for a private manufacturer and is a member of a bargaining unit represented by the International Brotherhood of Teamsters (IBT). He has served as a shop steward for many years. Due to an increasing number of missing parts in its assembly area, the company installed hidden security cameras in that area, as well as the employee locker rooms, to identify the source of the loss. Employees are permitted to place their own locks...
Walt, age 62, worked as an assembler for a private manufacturer and is a member of...
Walt, age 62, worked as an assembler for a private manufacturer and is a member of a bargaining unit represented by the International Brotherhood of Teamsters (IBT). He has served as a shop steward for many years. Due to an increasing number of missing parts in its assembly area, the company installed hidden security cameras in that area, as well as the employee locker rooms, to identify the source of the loss. Employees are permitted to place their own locks...
If you were a worker member of a union involved in collective bargaining for a new...
If you were a worker member of a union involved in collective bargaining for a new labor contract with management, and the union representatives and management representatives could not agree and were at an impasse, and your union representatives held a meeting of all the workers, including you, and presented the option to the workers to go on strike, discuss all of your concerns, both pro and con, as to whether you would vote to go on strike or to...
Why do whistle-blowers need protected? What risks do they face from their company? Find an example...
Why do whistle-blowers need protected? What risks do they face from their company? Find an example of an award given to a whistle-blower in the SEC Press Releases. Does the award adequately compensate the whistle-blower for the risk he or she took in exposing the company? Should the False Claims Act and the Dodd-Frank Act be expanded to cover all frauds? Why or why not? What are the drawbacks?
ASSIGNMENT It is recognized that insiders pose security risks due to their legitimate access to facilities...
ASSIGNMENT It is recognized that insiders pose security risks due to their legitimate access to facilities and information, knowledge of the organization and the location of valuable assets. Insiders will know how to achieve the greatest impact whilst leaving little evidence. However, organizations may not have employed effective risk management regimes to deal with the speed and scale of change, for example the rise of outsourcing. Outsourcing can lead to the fragmentation of protection barriers and controls and increase the...
For Questions 1-3: consider the following code: public class A { private int number; protected String...
For Questions 1-3: consider the following code: public class A { private int number; protected String name; public double price; public A() { System.out.println(“A() called”); } private void foo1() { System.out.println(“A version of foo1() called”); } protected int foo2() { Sysem.out.println(“A version of foo2() called); return number; } public String foo3() { System.out.println(“A version of foo3() called”); Return “Hi”; } }//end class A public class B extends A { private char service; public B() {    super();    System.out.println(“B() called”);...
Describe the two most significant risks involved in international financial management.
Describe the two most significant risks involved in international financial management.
What are the security risks involved in allowing cookies to be stored on your computer?
What are the security risks involved in allowing cookies to be stored on your computer?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT