DEVFYI - Developer Resource - FYI

Are the imports checked for validity at compile time? e.g. will the code containing an import such as java.lang.ABCD compile?

Java Interview Questions and Answers (part 3)


(Continued from previous question...)

491. Are the imports checked for validity at compile time? e.g. will the code containing an import such as java.lang.ABCD compile?

Yes the imports are checked for the semantic validity at compile time. The code containing above line of import will not compile. It will throw an error saying,can not resolve symbol
symbol : class ABCD
location: package io
import java.io.ABCD;

(Continued on next question...)

Other Interview Questions