class vehicle { protected float weight ; //in lbs private float topSpeed ; //mph } class train extends vehicle { public int noCarriages ; void printWeight() { //can access protected members but not //private members System.out.println( "weight: " + weight ) ; } } public class access2 { public static void main( String args[] ) { train trainObject1 = new train() ; //It's in the same package trainObject1.weight = 100 ; } //public static void main( String args[] ) }