UCD is located 5km south of Dublin city centre. Many buses serve the area stopping either outside on the filter-road to the dual-carriageway, or in the campus itself. The principal services are the 39A, 46A and 145. In working hours they come every 5 minutes. From Dublin city you can board them at various places, typically D'Olier Street (near O'Connell Bridge) or Kildare Street (near St. Stephen's Green). The last bus leaves from town at 23:30 so it should be easy to get back to UCD if you are staying there and want to go into the centre to eat and drink.
The fare is 3 euro payable to the driver in coins. No change is given.
However, if you pay with a leap-card, it costs 2.25 euro. You can buy a leap-card for 5 euro at the airport or online. The 5 euro is in principle refundable at the end of your stay if you have a euro bank account in the EU. An alternative is to buy a Visitor Leap Card that allows unlimited travel on the Dublin Bus network although it is only offered in quanta of 1,3 or 7 days. This includes travel on the 747 airlink 'express' from the airport to the centre, which purchased alone costs 7 euro single, 12 euro return.
To get from the airport to UCD, the easiest and most comfortable option is to take the blue Aircoach service on the Sandyford route. This departs every 15 minutes and costs 10 euro single (16 return). It take about an hour. You can also make the journey using Dublin bus with Bus 16 or 41 into the Centre, and then 39A, 46A or 145 to UCD. (Pack plenty of coins as this costs 3.30 euro into town and 3.00 out again, or 3.75 in total with a leap card.) A taxi to the university will cost about 40 euro. Make sure the driver takes you through the city. If you take the tunnels and toll bridge it will be an extra 5 euro, although it might be faster depending on traffic. On no account should you take the scenic route via the M50 motorway. Unscrupulous drivers will often try this one on and land you with a bill for 70 euro on arrival at the university.
Taxis from the centre of Dublin to UCD cost about 20 euro.