When should you use querySelector and when should you use getElementById?
They answer different questions, and they are not interchangeable. GetElementById takes an exact element id and returns that one element or null. QuerySelector takes a full CSS selector, so it can match by tag, by class, by attribute or by any combination, and it returns the first match in document order.
For a plain id lookup, getElementById is the right tool. It is a direct hash lookup rather than a selector match, so it is faster and it never throws. If the id does not exist you get null.
For everything else, querySelector is the better tool. It expresses intent in one string, and the selector syntax means you can do things that have no equivalent with getElementById, such as finding the first element with a given class or the first list item inside a particular list.
There is one classic mistake to warn about. The older getElementsByClassName and getElementsByTagName methods return a live collection, which is a live HTMLCollection that updates as the page changes. It is not a real array, it has no forEach method, and iterating it while changing the page can produce surprising results. The querySelectorAll method returns a static array instead, which is almost always what you want.
Two more notes for an interview. The getElementById method only works with an id attribute, and putting the same id on two elements is invalid markup even though the method would return the first one. And when you need many elements, querySelectorAll is the answer, returning an array you can loop over with forEach or map.