Skip to main content

Posts

Showing posts with the label default access modifier

java private

Access Modifier:- There are four access modifiers are available in java . public private protected default In java by default modifier is default if we are not using any modifier then by default access modifier will be default modifier. Applicable access modifiers for outer classes are default and public only. We cannot use private or protected modifier for outer classes. If we use   private or protected   modifier for outer class then compiler gives below error. private  class Student1 { } C:\JAVATECH>javac Student1.java Student1.java:1: error: modifier private not allowed here private class Student1         ^ 1 error protected class Student1 { } C:\JAVATECH>javac Student1.java Student1.java:1: error: modifier protected not allowed here protected class Student1         ^ 1 error If we use   default   modifier than w...