File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Head First Android this week in the Android forum!
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

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 ) {
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 Anilprem
Enthuware Software Support
Ranch Hand

Joined: Sep 23, 2000
Posts: 3493
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?)
Get Certified, Guaranteed!
(Now Revised for the new Pattern)

[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:
subject: One of the Mock Questions Cannot be Compiled
It's not a secret anymore!