• 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

Date ambiguity at go4java

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
From http://www.go4java.20m.com/index.htm I encountered the following question:
Q27.What will be the result of compiling and running the given program?
Select any two.

1. Compile time error as Date class is defined in both of the above packages.
2. Run time error as Date class is defined in both of the above packages.
3. It will compile and run without any error.
4. It will compile and run if we use .Date instead of .* in any one of the two import statements
The answers given are 1 and 4. I believe that answer 4 is incorrect. If you change the import statement to "import java.sql.Date", then you get a compile error as the java.sql.Date class specifies no constructor without an argument. That is, you can't have "java.sql.Date d = new java.sql.Date()". Of course, if you specify "import java.util.Date", then the program will compile.
Bill
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you're absoulutely right Bill. Choice 4 is incorrect unless it explicitly mentions importing java.util.Date.

Asma Zafar,
Sun Certified Programmer for Java2 platform.
[This message has been edited by Asma Zafar (edited August 25, 2001).]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic