top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Are the imports checked for validity at compile time?

–4 votes

e.g. will the code containing an import such as java.lang.ABCD compile?

posted Mar 26, 2014 by Prachi Agarwal

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Let me google it for you and found first link (may be a famous interview question)

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
answer Mar 26, 2014 by Luv Kumar
Similar Questions
+2 votes

I assume that constant must be initialized to a constant value at compile time, but following code the return value of ge_const() is assigned to x which will be collected at run time. So this must cause an error but I am getting the output as 50. Can someone clarify the detail?

    const int x = get_const();
    printf("%d", x);
int get_const()
    return 50;
–2 votes

e.g. Does importing com.MyTest.* also import com.MyTest.UnitTests.*?

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.