• 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
  • Ron McLeod
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Rob Spoor
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Carey Brown
Bartenders:

One of the Mock Questions Cannot be Compiled

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got this question form JQPlus:
public class Tester {
static String s1 = sM1("a");
{ s1 = sM1("b"); }
static {
s1 = sM1("C");
}
public static void main( String args[] ) {
Tester it = new Tester();
}
private static String sM1( string s ) {
System.out.println(s);
return s;
}
}
The answer is that 'a','c','b'will be printed in that order. However, I could not compite the program when I tried to test it myself. My attempt to fix the program failed. how should it be fixed?
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey there JiaPei,
I got it to work simply by capitalizing the S in string in the method header of sM1(String s).
Let me know if that doesn't work for you.
Paul
 
Enthuware Software Support
Posts: 4666
51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good catch!
In line : private static String sM1( string s ) {
change small case 's' of "string" to "String".
(Could you please tell me the Question Id, so that I can fix it?)
-Paul.
------------------
Get Certified, Guaranteed!
(Now Revised for the new Pattern)
www.enthuware.com/jqplus

[This message has been edited by Paul Anil (edited November 29, 2000).]
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hay that was just a typing mistake, as all u need to fix up your probem is change the parameter in your method sM1() to String instead of string. that is all, now u can eaisly run the program
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic