A class CorporateServiceImpl is implementing an interface called CorporateService. Here I know that the CorporateServiceImpl class never be used outside of the package. I will use the implemented method of the CorporateServiceImpl through the interface. In that case, what should be the access modifier of the CorporateServiceImpl class? Currently, I am preferring protected so that other classes of the package could use this. Is my implementation correct? Or it should be public?
What should be the access modifier of ServiceImpl Class?
62 Views Asked by Rejaul Karim At
2
You always have to use at least one Public Class in your java file, otherwise it won't be compiled to .class file in JVM. Only methods and fields are behaved as private or protected. If you want to have a private or protected class for example, you need to declare them in another Public class.