fork download
  1. class Vehicle{
  2. String colour;
  3. private int number;
  4. void set(int number)
  5. {
  6. number=number;
  7. }
  8. int get()
  9. {
  10. return number;
  11. }
  12. }
  13.  
  14. class Car extends Vehicle{
  15. public static void main(String[] args) {
  16. Vehicle v = new Vehicle();
  17. v.colour = "white";
  18. v.set(1010) ;
  19. System.out.println(v.colour + " " + v.get());
  20. }
  21. }
Success #stdin #stdout 0.11s 35936KB
stdin
Standard input is empty
stdout
white 0