Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes One of the Mock Questions Cannot be Compiled Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "One of the Mock Questions Cannot be Compiled" Watch "One of the Mock Questions Cannot be Compiled" New topic
Author

One of the Mock Questions Cannot be Compiled

JiaPei Jen
Ranch Hand

Joined: Nov 19, 2000
Posts: 1309
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?
Paul Caudle
Ranch Hand

Joined: Jun 08, 2000
Posts: 64
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
Paul Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3314
    
    8
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).]


Enthuware - Best Mock Exams and Questions for Oracle/Sun Java Certifications
Quality Guaranteed - Pass or Full Refund!
umang bhartia
Ranch Hand

Joined: Sep 29, 2000
Posts: 60
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: One of the Mock Questions Cannot be Compiled