Computer Applications
Declare a public class CoolClass.
- Write the header for a public member method CoolMethodA.
- Write the header for an integer member method CoolMethodB that should be accessible to the classes in the package but not to derived classes.
- Write the header for an integer member method CoolMethodC that should be accessible only to other methods of the class.
- Write the header for a character member method CoolMethodD that should be accessible to the classes in the package and any derived classes.
Encapsulation & Inheritance in Java
6 Likes
Answer
public class CoolClass
{
public void CoolMethodA() {
}
int CoolMethodB() {
}
private int CoolMethodC() {
}
protected char CoolMethodD() {
}
}
Answered By
5 Likes