• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

question 57 from Marcus Green mock exam

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of the following statements are true?
1) Adding more classes via import statements will cause a performance overhead, only import classes you actually use.
2) Under no circumstances can a class be defined with the private modifier
3) A inner class may under some circumstances be defined with the protected modifier
4) An interface cannot be instantiated
Right answers: 3 and 4
-------------------------------------------------
In my opinion 1) should be also true. I understood
Mr. Green explanation but consider this: I had a
big project with many authors before me; one of
them (not a real Java programmer considering his
code added in the import statements (of all
the code that he touched) all the possible classes
that were slightly close to the subject (probably just to make sure that everything is compiling fine and not to miss something, but he didn't care
that in fact half of the import statements waren't
necessary in the actual piece of code!). I was allowed( even encouraged by my mentor=guru, when he heard about it) to get rid of the unnecessary import statements and this made the code more robust actually! So quick question: what is your
opinion about this ?
Thanks in advance,
Michael
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some people have discussed the issue of imports and performance in the Performance forum.
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=15&t=000240
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=15&t=000305
http://www.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=15&t=000332
[ April 06, 2002: Message edited by: Marilyn deQueiroz ]
 
arch rival
Posts: 2813
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why would adding more classes via import statements cause a performance overhead?
Marcus
 
Michael Pavlov
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi again,
I fallowed the links and I got what you said.
I was talking not only about wildcard imports of packages and the regular classes from the API (in which case you are perfectly right ofcourse!),
but especially about new classes being part of a
large application (like the one that I mentioned)
with more then 1000 java classes. We (my team)
observed that the product was faster meaning that
the time for execution was with 30-150 seconds
shorter then in the past ( the range is related
with what particular feature from within that product did you choosed to execute). That's all.
However, I'm not sure how this affected the compilation when all files get loaded, or the
runtime, but what I noticed is that the product
was a little bit faster after the elimination
of the import statements of classes not involved
in the actual piece of code...
Thank you very much for your input,
Best Regards,
Michael
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic