Why do we need to specify import statement ? Don't you think Java could have been designed in such a way to automatically import everything that's in the class path ?
Javasearch.buggybread.com
Share

Search Interview Questions


 3358 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Java - Interview Questions and Answers

 Q1. Why do we need to specify import statement ? Don't you think Java could have been designed in such a way to automatically import everything that's in the class path ?Core Java2018-02-04 18:50:16

Ans. Java could design it in such a manner but would result in ambiguity if there are multiple files with the same name. The only way to get over it to show the message when you use any such class to provide explicit import with the package prefix. The other problem could be that Java might have to change the early import to Late import and check what's being used to decide what needs to be imported as otherwise you will see errors regarding the ambiguous imports with duplicate file name.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     import      expert


Related Questions

  What are concepts introduced with Java 5 ?
  Can I import same package/class twice? Will the JVM load the package twice at runtime?
  What is "Import" used for ?
  What is a Static import ?
  Do we need to import java.lang package ?
  Which of the following syntax is correct ?
 Does importing a package imports all its sub packages too ?
 Is it a good practice to use Asterick(*) in import statement to load multiple packages with single import statement ?
 Why is it important to close files and streams ?
 Difference between import and include directive in jsp




Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked:
         

X Close this