Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Return Type required Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Return Type required" Watch "Return Type required" New topic
Author

Return Type required

PETER CARTER
Ranch Hand

Joined: Aug 28, 2004
Posts: 70
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 !!
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
What does this mean to you? Is it a method or what?
[ September 15, 2004: Message edited by: Barry Gaunt ]

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
s choukse
Greenhorn

Joined: Dec 12, 2001
Posts: 27
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.
Jeff Lloyd
Greenhorn

Joined: Sep 15, 2004
Posts: 4
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Return Type required
 
Similar Threads
Why Compilation fails here???
scjp exam problem
static modifier
Can u pls explain this
scjp help required