Entities can have passengers. A good example of a passenger is a Player riding a saddled pig, or a zombie inside a minecart.
Although there are specific vehicles, any entity can be a vehicle for any other entity with the SetPassenger method.
Entity vehicle;
Entity passenger;
boolean result = vehicle.setPassenger(passenger); //False if couldn't be done for whatever reason
The passenger should now be attached to the vehicle
You can check if an entity has a passenger using
boolean hasPassenger = entity.isEmpty()
If the entity has a passenger, you can retrieve the passenger entity with
Entity passenger = entity.getPassenger();
Will only return the primary passenger if the vehicle can have multiples.
Finally, you can eject an entity's passenger with
boolean b = entity.eject(); //Eject all passengers - returns true if there was a passenger to be ejected