Sunday, 27 July 2014

Why we cant make class as private and protected

Why we cant make class as private and protected?

Private - 
What are other benefits you will get , if class declare as private ?
         Can we able to create object for private class from other class ? : No
         We cannot access the any of member (fields, methods ) of private class , then what is use of it ?



Protected-
If declared the class as protected - only via inheritance can access the fields and member , any other class who is not belong to protected class ( i.e . class is not inherited ) : it cont access any of fields and methods . 


No comments: