No it is not legal, you are required to deregister (Abmeldung) at least 2 weeks after moving out
- a registration (Anmeldung) elsewhere within Germany fulfills this requirement
A Abmeldung will stop all official post (which may contain any deadlines) from being sent.
So if you remained registered with your parents and can react in some form to any official post (i.e. the parents inform you of the post)
- you can remain registered there
If you sub-let an existing residence while you are abroad
- a Abmeldung is needed
- for the tax office you would then remain beschränkt steuerpflichtig (limited taxable) for such an income
There is also a definition of what is considered a
residence
- so you cannot reside within a post office box
Bundesmeldegesetz (BMG)
§ 17 Anmeldung, Abmeldung
(1) Wer eine Wohnung bezieht, hat sich innerhalb von zwei Wochen nach dem Einzug bei der Meldebehörde anzumelden.
(2) Wer aus einer Wohnung auszieht und keine neue Wohnung im Inland bezieht, hat sich innerhalb von zwei Wochen nach dem Auszug bei der Meldebehörde abzumelden. Eine Abmeldung ist frühestens eine Woche vor Auszug möglich; die Fortschreibung des Melderegisters erfolgt zum Datum des Auszugs.
...
Section 17
Registration, deregistration
(1) Anyone who moves into a residence shall register with the registration authorities within two weeks of moving in.
(2) Anyone who moves out of a residence and does not move into another residence in Germany shall deregister with the registration authorities within two weeks of moving out. Deregistration shall be possible no more than one week before moving out; the population register shall be updated as of the moving-out date.
...
Bundesmeldegesetz (BMG)
§ 20 Begriff der Wohnung
Wohnung im Sinne dieses Gesetzes ist jeder umschlossene Raum, der zum Wohnen oder Schlafen benutzt wird. Als Wohnung gilt auch die Unterkunft an Bord eines Schiffes der Marine. Wohnwagen und Wohnschiffe sind nur dann als Wohnungen anzusehen, wenn sie nicht oder nur gelegentlich fortbewegt werden.
Section 20
Definition of residence
A residence as defined in this Act is any closed space used for living or sleeping. Accommodation on board a Navy ship shall also be considered a residence. Caravans and barracks ships shall be regarded as residences only if they are stationary or rarely moved.
Sources: