A ring with exactly one maximal ideal is called a local ring [1]. We write (R, \mathfrak{m}) for a local ring R with maximal ideal \mathfrak{m}, and call the field R/\mathfrak{m} its residue field. Throughout, rings are commutative with 1 \neq 0. The definition is a condition on ideals, but it can be checked on single elements.
For a ring R the following are equivalent [1,2]: (i) R has exactly one maximal ideal; (ii) the non-units of R form an ideal; (iii) for every a \in R, at least one of a and 1 - a is a unit. Condition (iii) is often the easiest to test, since it looks at one element at a time.
From (i) to (ii): a non-unit a generates a proper ideal (a), which lies in some maximal ideal, so a \in \mathfrak{m}; and no element of \mathfrak{m} is a unit. So \mathfrak{m} is exactly the set of non-units. From (ii) to (iii): if a and 1 - a were both non-units, their sum 1 would be a non-unit too.
From (iii) to (i): if \mathfrak{m} and \mathfrak{n} were two different maximal ideals, then \mathfrak{m} + \mathfrak{n} = R, so 1 = a + b with a \in \mathfrak{m} and b \in \mathfrak{n}. Then neither a nor 1 - a = b is a unit, against (iii). Since a ring with 1 \neq 0 has at least one maximal ideal, it has exactly one.
An example from analysis. Take the continuous real functions defined near the origin 0 of the plane, and regard two of them as the same when they agree on some disk around 0. These classes are called germs at 0, and with pointwise sums and products they form a ring C_0.
If f(0) \neq 0, continuity gives a disk around 0 on which f has no zero, and 1/f is defined there, so f is a unit of C_0. If f(0) = 0, then (fg)(0) = 0 for every g, so f is not a unit. The non-units are the germs vanishing at 0, an ideal \mathfrak{m}, and C_0 is local with C_0/\mathfrak{m} \cong \mathbb{R} through f \mapsto f(0).
In the figure, the curves f = 0 and f = 1 never meet, so the origin lies on at most one of them, and f or 1 - f is a unit. The shaded disk is the larger of the two disks around 0 on which f or 1 - f has no zero. When f(0) = 0, the disk of f shrinks to the origin, while 1 - f keeps a large one.
Fix a prime p, and let \mathbb{Z}_{(p)} be the set of rational numbers that can be written as a/b with a, b \in \mathbb{Z} and b \notin p\mathbb{Z} [2]. Since b, d \notin p\mathbb{Z} implies bd \notin p\mathbb{Z}, sums and products stay in this set, so \mathbb{Z}_{(p)} is a subring of \mathbb{Q} containing \mathbb{Z}. For example, 1/2 and 5/7 lie in \mathbb{Z}_{(5)}, but 1/5 does not.
Write x = a/b in lowest terms. If a \notin p\mathbb{Z}, then b/a also lies in \mathbb{Z}_{(p)}, and x is a unit. If a \in p\mathbb{Z}, the only candidate for an inverse is b/a, whose denominator in lowest terms is divisible by p, so x is not a unit. The non-units are the fractions with numerator divisible by p; they form the ideal p\mathbb{Z}_{(p)}, and \mathbb{Z}_{(p)} is local.
Taking the powers of p out of the numerator, every nonzero x can be written as x = up^n with u a unit and n \geq 0. So a nonzero ideal is generated by p^n for the smallest n occurring in it, and the ideals form one chain \cdots \subsetneq (p^2) \subsetneq (p) \subsetneq (1) together with (0).
The residue field is \mathbb{Z}_{(p)}/p\mathbb{Z}_{(p)} \cong \mathbb{F}_p, where a/b goes to \bar{a} \cdot \bar{b}^{-1}, which exists because b \notin p\mathbb{Z}. For p = 5, 1/2 goes to 3, since 2 \cdot 3 = 6. In the figure, the class of 0 collects \mathfrak{m} = 5\mathbb{Z}_{(5)}; the sum 5/7 + 10/3 = 85/21 stays in it, and 1 - 5/7 = 2/7 falls into the class of 1.
A ring homomorphism \varphi \colon R \to S between local rings (R, \mathfrak{m}) and (S, \mathfrak{n}) is called local if \varphi(\mathfrak{m}) \subseteq \mathfrak{n}, or equivalently, if a is a unit whenever \varphi(a) is. The reduction \mathbb{Z}_{(p)} \to \mathbb{F}_p is local. The inclusion \mathbb{Z}_{(p)} \to \mathbb{Q} is not: p lies in p\mathbb{Z}_{(p)}, but in \mathbb{Q} it is a unit, outside the maximal ideal (0).
Other local rings appear in the same way. In the ring k[[x]] of power series over a field k, a series with nonzero constant term is a unit, as in (1 - x)^{-1} = 1 + x + x^2 + \cdots, so the non-units form the ideal (x). The rings \mathbb{Z}/p^a from the article on the Chinese remainder theorem are local as well.
Not every ring is local. In \mathbb{Z}, both 3 and 1 - 3 = -2 are non-units, and the maximal ideals (2), (3), (5), \ldots are infinitely many. Over a field k, the polynomial ring k[x] has a maximal ideal for each monic irreducible polynomial. Both become local only after we allow suitable denominators, as \mathbb{Z}_{(p)} does for \mathbb{Z}.
A ring with only finitely many maximal ideals \mathfrak{m}_1, \ldots, \mathfrak{m}_r is called semilocal [1]. Distinct maximal ideals are coprime, so the Chinese remainder theorem gives R/J \cong R/\mathfrak{m}_1 \times \cdots \times R/\mathfrak{m}_r, where J = \mathfrak{m}_1 \cap \cdots \cap \mathfrak{m}_r is the Jacobson radical. Modulo J, a semilocal ring is a product of r fields, and a local ring is the case r = 1.
Let R be the set of fractions a/b with b \notin 3\mathbb{Z} \cup 5\mathbb{Z}. As for \mathbb{Z}_{(p)}, a fraction in lowest terms is a unit exactly when its numerator lies outside 3\mathbb{Z} \cup 5\mathbb{Z}. So the non-units form the union of the ideals 3R and 5R, with R/3R \cong \mathbb{F}_3 and R/5R \cong \mathbb{F}_5.
Every proper ideal I lies in 3R or in 5R. If not, I has an element x outside 3R and an element y outside 5R. If either lies outside both ideals, it is a unit; otherwise x \in 5R and y \in 3R, and the numerator of x + y is divisible by neither 3 nor 5. Hence 3R and 5R are the only maximal ideals, J = 15R, and R/15R \cong \mathbb{F}_3 \times \mathbb{F}_5.
Yet R itself does not split into a product. A product A \times B of nonzero rings contains the idempotent (1, 0), while R lies in \mathbb{Q} and is a domain, where e^2 = e forces e = 0 or e = 1. The splitting of R/J does not lift to R, unlike k[x]/(x(x - 1)) \cong k \times k, where the Chinese remainder theorem applies to the coprime ideals (x) and (x - 1) of k[x] itself.
Germs at the two points 0 and 1 of the real line behave differently. Continuous functions defined near 0 and near 1, regarded as the same when they agree near both points, form a semilocal ring. Its maximal ideals are \mathfrak{m}_0 and \mathfrak{m}_1, the germs vanishing at 0 and at 1; the argument above works with values in place of numerators.
Here the function e that equals 1 near 0 and 0 near 1 is an idempotent, and f = ef + (1 - e)f splits the ring into germs at 0 times germs at 1. The first part of the figure shows ef agreeing with f only near 0, and (1 - e)f agreeing with f only near 1.
Rational functions defined at 0 and 1 form a semilocal ring with the same two maximal ideals, but it lies in the field \mathbb{R}(x), so its only idempotents are 0 and 1. In the second part of the figure, g = (1 - x)(1 + sx) has g(0) = 1 and g(1) = 0 for every s, yet g^2 - g vanishes only at the two points, never on a whole interval.
So whether a semilocal ring is a product of local rings is a question about idempotents, the same question as whether its spectrum is connected, which came up in the article on irreducible components.