Hello english teachers.. I am so confused with this negative sentence;(?

example 1
John doesn't have any children, and NEITHER does Mary.

Example 2
John has three children, and SO does Mary.

how can I master it? I've never really heard those kind of sentence in regular conversation.. but to me those sound so good and proper sentence..
3 answers 3