/* Author: James Tam Version: February 26, 2021 */ public class P { private String pAttribute; public P(String aString) { setPAttribute(aString); } //There isn't a real functional need for this method in this example, it's included just to //show the mechanics of the protected access level (in case you wonder why it's set to protected). protected void childAccessable() { System.out.println("Protected method can be accessed within parent and child classes"); } public String getPAttribute() { return(pAttribute); } public void setPAttribute(String aString) { if (aString == null) System.out.print("Attempting to set attribute to a null value"); else pAttribute = aString; } public String toString() { String aString; aString = "Parent attribute = " + pAttribute; return(aString); } }