do the subdomain get the authority from main domain?

If I make one subdomain of one spammy website, will the subdomain mark as spammy/penalized site?Or if it's a good website, will it get the authority of that domain?