• 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

main(), PrintWriter and Collection

 
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1.)
The Java 2 Cert guide has question...
Which of the ff. signatures are valid for
the main() method entry point of application.
the answers are...
public static void main(String args[])
public static void main(String[] args)
public static int main(String args[])
how come the third one?

2.)
Another is.. in java API docs...
The class PrintWriter states...
Methods in this class never throw I/O exceptions. The client may inquire as to whether any errors have occurred by invoking checkError().
..but methods such flush(),close(),write(),print()
throws IOException... is this contradicting?
3.) About Collection...
Is there any
real world application or practical application
that uses collection classes?
All i know is for table of information than can
use for database application.
Thanks...
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure about the first two, but Collections are used all the time. If you write a video store application, you'll need to keep a List of videos the customer is renting. Maybe you'll have an employee screen, so you'll want to display a Set of all the employees on the screen. If you want to keep track of the days overdue for each video, you could have a Map with the video as key and days late as value.
I hope these few examples help.
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Methods in the PrintWriter class don't throw exceptions. Inherited methods might.
 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
RE: First question of the three - main signatures.
Which Java Certification guide are you using
for this?
The reason I ask is when I was studying for my Cert (it's been almost 2 years now) I had used the Boone and Stanek book which was horrible!
It was riddled with so many errors that the only value the book had was that I had to check every single thing to verify it was correct so I learned stuff that way.
The Java 2 Exam Notes and Java 2 Exam Cram books were great and when I sent some errata to Sybex for the Java 2 Exam Notes they sent me a nice e-mail from the publisher and another e-mail from the author confirming the errors.
In my opinion, the first two are in fact valid signatures if you want the main() to run because you can have the array declaration on either side.
It could be that they're saying the third is a valid signature in general but it will not work if you're trying to use it as the 'main' called to run as an application. You may want to e-mail them and ask for clarification.
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Question 1 is an error and was corrected in later printings.
 
Nelson Nadal
Ranch Hand
Posts: 170
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks for the time you spent to answer...I appreciate it very much...
 
A day job? In an office? My worst nightmare! Comfort me tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic