• 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

Return Type required

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1. public class Alpha{
2. private static Character() ids;
3.
4. public static void main( String[] args){
4. ids = new Character[args.length];
5. for (int i=0; i<ids.length; i++){
6. ids[i] = new Character( args[i] );
7. System.out.print( ids[i] );
8. }
9. }
10. }
What is correct?
A. Compilation fails.
B. The code runs with no output.
C. An exception is thrown at runtime.
D. The code runs, outputing a concatenated list of the arguments passed to the program.
Answer: A
Explanation: Compilation fails. Line 2: Return Type required
Why ??
Thanks !!
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does this mean to you? Is it a method or what?
[ September 15, 2004: Message edited by: Barry Gaunt ]
 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Buddy, either you need to type the questions correct or please specify the source. Most important please try the questions yourself before you post on the ranch.. atleast run the code once.
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Presumably the round brackets on line 2 make the compiler think you are trying to declare a public static method which would require a return type that is missing. If the brackets were [] then you're declaring an array variable and the compiler is happy.
reply
    Bookmark Topic Watch Topic
  • New Topic