A host that wants to reach an address outside its own subnet sends the packet to its default gateway, a router, and stops thinking. The router looks at the destination address and consults its table, a list of network prefixes each paired with a next hop or an interface. It picks the most specific entry that matches, the longest prefix, and forwards the packet there. The next router does the same. Nobody plans the whole path; each router makes one local decision, and the path is the sum of them. That is why a routing problem is found by walking the path and asking each router what it would do with this packet, rather than by reasoning about the network as a whole.
How the table is filled
Static routes are typed in by an administrator and never change unless a person changes them; they are right for small networks and for the default route toward the internet. Dynamic routing protocols let routers tell each other what they can reach and recompute paths when a link fails. Inside an organisation that is usually OSPF, which floods link state and computes shortest paths; between organisations on the internet it is BGP, which exchanges reachability and policy rather than distance, and whose misconfigurations make the news. Cloud networks hide most of this behind route tables you edit in a console, which are static routes with a nicer interface.
Two properties decide most behaviour. The longest match wins, so a specific route to one small subnet overrides a broad route that also covers it, which is how traffic is steered and how a stray specific route hijacks it. And the default route, written as a prefix of length zero, matches everything not matched by anything else, which is why a missing default route means the internet is unreachable while everything local works. The certifications examine both: the vendor-neutral paper asks which route a packet takes given a table; the Cisco exams ask you to configure and troubleshoot the protocols that build it; the cloud exams ask which route table entry a subnet needs to reach a gateway.
