Driveshafts and axleshafts transmit power farther down your drivetrain. In both cases, this path is not a fixed one. The driveshaft changes angle based on suspension movement, and the path of power through the front axleshafts to the wheels must change as the vehicle is steered. On an independent-suspension rig, power is transferred out to the tire while the suspension cycles up and down over terrain. In all these cases, we need a smooth transfer of power through a changing angle, and it's some type of joint that must perform that task.

Most of us are quite familiar with the single-Cardan U-joints used on all driveshafts. Two opposing yokes set 90-degrees apart are connected using a U-joint. At least one joint is needed at each end of a driveshaft.
There are essentially two types of power-transmission joints used on 4WDs: universal joints (U-joints) and constant-velocity (CV) joints.
A lone U-joint (single-Cardan) has only two axes of angular motion. Imagine a joint built by placing two hinges together but rotated 90 degrees with respect to each other. If you hold a driveshaft with a U-joint, you can see how the joint may swivel up and down and side to side. Rotational motion can be transferred through such a joint working at an angle. However, as the assembly rotates, the angular velocity at each of the two axes of the U-joint changes during rotation. Using a second U-joint at the other end of a driveshaft helps to cancel out this rotational speed variation and allows us to run a driveshaft at reasonable angles from horizontal with little or no driveline vibration.

The parts of a typical U-joint consist of the center cross, four steel bearing caps, needle bearings, and grease seals (shown red here). Joints may come with or without grease zerk fittings that allow periodic lubing of the bearings with a grease gun. If you spend a lot of time playing in mud or water, having the ability to easily reload the joints with fresh grease is a good idea.
Whenever you try to run a U-joint at too great an angle, maybe due to a lift, you may have trouble with the driveshaft vibrating or moving erratically. Because of the differing angular speeds at each joint, the steeper angle exaggerates the effect. At some point, this causes severe enough movement to cause accelerated joint wear and/or severe driveline vibration.
Constant-velocity joints behave just as their name implies. The joint is composed of two U-joints (double-Cardan) together or a set of grooved inner and outer races and a half dozen or so large ball bearings that allow the joint to articulate through angles while always providing a constant, smooth transfer of rotational energy.
Both U-joints and CV joints can be found in driveshafts and axleshafts. Birfield joints are a type of CV joint sometimes found in 4WD front axles.
Maintenance
As we happily cruise down the highway at 70 mph, a driveshaft is spinning and spinning and spinning. Every time it rotates, each U-joint speeds up and down in angular rotation. All this rides on that set of needle bearings and a layer of grease. That's a lot to demand from a component.

U-joints come in various sizes based on application and load rating. The center-cross size and overall dimensions increase as the rating goes up. On some joints all four caps are the same, and on other joints the cap pairs may have differing diameters based on their mating-yoke hole size.
Joints come with or without zerk grease fittings. Those without are prelubed from the supplier to last the life of the joint. Those with a grease fitting should receive a squirt of grease from time to time, or more often if you spend a lot of time in mud and water.
Typically, as a joint wears it will go from being well lubed and quiet to a drying joint that may give you warning by starting to squeak. Beyond this point, you start wearing metal on metal and the joint will begin to develop looseness between the cross and cap. At this point, a joint can come apart, leading to some serious drivetrain damage when it lets go.
A quick way to check for joint play while on a vehicle is to put the axle on jackstands with the transmission in Neutral and the parking brake applied. Then simply grasp and wiggle up, down, and rotationally, looking for any signs of looseness.

When a U-joint is installed in a yoke, each cap is held in place with a steel clip. On this driveshaft, the clips fit in a groove on the outside of each yoke ear. Some driveshafts accommodate C-clips on the inside of the yoke ears.
The rubber boots on CV joints used on axleshafts should be checked periodically for tears. The boot keeps the grease inside and the dirt outside. The two should not meet. Most boots require axleshaft or joint removal for replacement. Sometimes split boots are available that do not require shaft removal, but these aren't quite as reliable due the lesser ability of the split portion to flex during axle rotation.
When replacing the boot, be sure to repack the joint with fresh grease to increase its wear life. If the joint has been run dry or you hear clicking sounds from the joint, there's a good possibility you've got excessive joint wear and it's time for a new one.
Repair
U-joints can typically be replaced with a few simple tools. You'll need something to remove the clips that secure the joint in the driveshaft or axle yoke, then you'll need a way to push the joint one way and then the other to get it out of the yoke. A press provides the smoothest way to do this, but careful work with a hammer and drift can work, as can a good bench vise. We've even seen trail repairs done using rocks to knock out the U-joints in a pinch.
Driveshaft CV joints require similar tools for disassembly/assembly. Birfield joints require only a prybar or similar tool once the inner axleshaft is removed. The balls and inner pieces simply go in and out of the joint ball in a specific order and orientation. Other driveaxle CV joints may require common wrenches to separate the joint and axle parts.
 The cross on this driveshaft U-joint did break due to driveline stress. Once it let loose, the driveshaft was free to fall to the ground or flop around under the truck. This also resulted in damage to the yoke ears, rendering it unuseable. |  Here's an example of a badly neglected driveshaft U-joint. This one should have been replaced well before it was removed. The factory lube had badly diminished over the years, and the needle bearings were so worn that there was about 1/8 inch of play in the worn axis. One cap was also starting to break. Had this joint completely failed while driving, the result would not have been pretty. |  The CTM joints use a bronze sleeve in each cap instead of the usual needle bearings. This allows the cross pins to be made larger and stronger. The caps are periodically greased using a needle-tip adapter on a grease gun. An O-ring at each corner seals out dirt and keeps the grease inside. |
 CTM Racing makes these super-tough heat-treated U-joints for Dana 44 and 60 axleshafts. When used with upgraded chrome-moly axleshafts, driveline strength is greatly increased. These joints are also rebuildable. |  A driveshaft double-Cardan joint may be used in some applications. With two joints instead of one, the operational angle is greater. This configuration also serves as a constant-velocity joint because the variation in angular velocity of one joint is negated by that of the second joint. |  With this double-Cardan joint disassembled, you can see all of its components. There is a driveshaft yoke, a link or center yoke, and a socket yoke. A pair of U-joints (or spiders) connects the three yokes, and there is a small spring and retainer/thrust washer components in the assembly. |
 Here you can see a Birfield joint, which is one type of CV joint used on the front axles of some vehicles. The "bell" area is part of the outer front stub axle. Unlike a U-joint that can reside in an open knuckle area, this type of joint must be housed in a closed knuckle assembly due to the exposed grease and internal parts. |  This photo shows the internal parts of a Birfield joint. Six large ball bearings ride in grooves cut in the inner wall of the "bell" area and mate to matching grooves in the inner race. A steel cage keeps the parts in place. The inner axleshaft engages the assembly via splines in the inner race. |  A Birfield joint can fail when overstressed by the bell cracking open, as seen here, or by the inner race and cage crumbling inside. Drive joints are strongest when at zero angle, and the assembly is weaker as working angle increases. |
 A common sight on desert racers and buggies is a CV joint used on an independent drive axle. Unlike a Birfield joint that resides inside a closed knuckle, the CV joint is enclosed with a plate and boot on one end and with the flanged plate of the outer axle on the other. |  Here you can see an open CV joint and its mating outer axleshaft. The innards of this joint are much the same as the Birfield joint shown above. The balls, races, and cage would be greased prior to assembly. In a CV joint, the inner splined race can typically accommodate axleshaft movement by allowing the shaft to slide in the splines. |  Here's another example of a small U-joint. This Borgeson steering-shaft joint flexes on needle bearings and mates to the steering-box input and steering wheel via splined shafts. |