Home difference between inheritage and creating new object
 I have a question. What is the difference between these two: class Machine { int x = 2; } class Car { public void start(Machine abc){ abc.x = 10; } }  And: class Machine { int x = 2; } class Car extends Machine { public void start(){ x = 10; } }  I know that in the first example I'm creating kind of new object (am I right?) in Car class and I can use variable x from Machine class, and in the second example I'm inheriting from class Machine to class Car, so I can use variables from Machine in Car. But I don't know when should I use first one and when the second one, which is better, and so on. Could someone explain me the difference?