Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Access Modifiers

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 184
    Comment on it

    Access modifiers in java are used to control the access of other classes to access the class or method.

    There are different type of access modifiers used

    1.Public-It is the default access modifier it means that your class or method is visible to all other classes and method but in its package.

    2.Protected-It can be accessed by any class in its package and by subclass that extends it from another package./

    3.Private-It can be accessed in it own class only.

    public class Bicycle {
    
        private int cadence;
        private int gear;
        private int speed;
    
        // add an instance variable for the object ID
        private int id;
    
        // add a class variable for the
        // number of Bicycle objects instantiated
        private static int numberOfBicycles = 0;
            ...
    }
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: