Question: You are given the following code: public class AccessModifiers { public String publicString = I'm public; private String privateString = I'm private; protected String protectedString
You are given the following code:
public class AccessModifiers {
public String publicString = "I'm public";
private String privateString = "I'm private";
protected String protectedString = "I'm protected";
String defaultString = "I'm default";
public void printStrings() {
System.out.println(publicString);
System.out.println(privateString);
System.out.println(protectedString);
System.out.println(defaultString);
}
}
You are asked to add the following to test the code above:
Create another class called Main and add the main method. Display each access modifier and call the printStrings() method of the AccessModifiers class
Explain if there is any error.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
