The boys classmates put a dream-inducing microchip into his cereals (I think) as a prank. He then dreams in the subway home, but oversleeps, and eventually somehow accidentally leaves his walled-off city, I think by way of tripping into a garbage disposal chute. He can't just go back in.
The book happens very far into the future.
Outside, there is almost nothing; The city is not supposed to be entered or left. The boy does meet an old man, though, which I think is the only other human character in the novel. The existence of other cities is mentioned, but there is no known contact between any of them.
The boy and the old man eat mostly canned goods, which the city dwellers throw away, even though it is perfectly fit for consumption. This is also how they meet: Since the boy left the city trough garbage disposal, he landed where the man gathered food.
Around the town, there are three(?) towers, some kind of power-generators or shield-generators or something. The boy and the old man work together to... destroy them, or connect them, or something.
I distinctly remember Faraday cages being an integral part of the story. That is, the boy hides inside a Faraday cage from some sort of guard robot, which had sensor that could not notice the boy through the cage. This happens in some sort of museum or warehouse. The boy discovered the hiding effect of the cages for himself, the old man did not previously know this, I believe.
At the end, the boy throws himself into a beam of light, or electricity, or a manifestation of an evil artificial intelligence, or something like that, to connect a cable into it. I think he also used a Faraday Cage at the end here, but I'm not sure.
I've first read this book about 10-15 years ago, in a smallish German library. I have no idea how old it was at the time.