Results 1 to 2 of 2
  1. #1
    Big-D is offline Member
    Join Date
    Mar 2012
    Rep Power

    Default has private access in error

    I've been doing some inheritance lately, and I've writen several programs that use it, and am now encountering the error "_____ has private access in _____". I've done the exact same thing with all my other inheritance programs, so I'm not sure what is wrong. This is the code that I'm getting it on "Driver has private access in Car" is the exact error
    Java Code:
    public class DailyDriver extends Car
       private boolean Student;
       private boolean Worker;
       private boolean businessMan; 
       private double milesPerDay;
       public DailyDriver(Car carDriver, boolean s, boolean w, boolean b, double m)
           milesPerDay = m;
           Student = s;
           Worker = w;
           businessMan = b;
    and here is the superclass(at least the constructor)
    Java Code:
    public class Car
        private int Year;
        private String make;
        private int speed;
        private String Type;
        private String Name;
        private String Driver;
        public Car (int Year, String carMake, int topSpeed, String carType, String carName, String carDriver)
            this.Year = Year;
            this.make = carMake;//brand(ford, chevrolet, etc.)
            this.speed = topSpeed;//top speed
            this.Type = carType;//sports car, luxury, exoitic, etc.
            this.Name = carName;//Mustang, cammaro, etc.
            this.Driver = carDriver;//Teenager, Adult, etc.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Eastern Florida
    Rep Power

    Default Re: has private access in error

    There are several problems here besides private: no matching constructor and Driver is not initialized yet when you are trying to use it.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Default / package-private access
    By genkuro in forum New To Java
    Replies: 1
    Last Post: 12-30-2010, 06:08 AM
  2. Replies: 17
    Last Post: 10-14-2010, 10:26 PM
  3. has private access error message
    By ibrahimyoussof in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 04-13-2010, 04:01 PM
  4. Replies: 3
    Last Post: 03-14-2009, 07:22 AM
  5. How to access private data types from public classes?
    By kevzspeare in forum New To Java
    Replies: 3
    Last Post: 03-07-2009, 04:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts