Toymods Car Club
www.toymods.org.au
F.A.Q. F.A.Q.    Register Register    Login Login    Home Home
Members Members    Search Search
Toymods » The Outhouse » Java interview questions...

Show: Today's Posts  :: Show Polls 
Email to friend 
Return to the default flat view Create a new topic Submit Reply
AuthorTopic
ehendrikd
Forums Junkie


Location:
ballarat
Registered:
April 2003
 
Re: Java interview questions... Tue, 03 February 2004 22:50 Go to previous messageGo to previous message
Nark wrote on Tue, 03 February 2004 20:03

29. Why do you Canvas ?


sounds a little bit japlish Confused

on a different note...

has any one ever noticed that the String object in java is the only object in java that is passed by value? and i dont think this is documented (or i havent found where it is documented). a while ago i remember trying to use a recurisve method that was passed a String and altered that string, and after the recursive method finished, there was no change to the string. i had to create a wrapper class that had one string as a member and pass that to the method. i just think its is a litle strange they diddn't tell us about this.

eg....

public class StringByValue {
	public static void main(String psAryArgs[]) {
		String sText = "";
		recursiveMethod(sText, 0);
		System.out.println("sText ->" + sText + "<-");
		StringWrapper oText = new StringWrapper("");
		recursiveMethod(oText, 0);
		System.out.println("oText ->" + oText + "<-");
	}
	public static void recursiveMethod(Object poObject, int piCount) {
		if (piCount == 10) {
			return;
		}
		if (poObject instanceof String) {
			String sText = (String)poObject;
			sText += String.valueOf(piCount);
		} else {
			StringWrapper oText = (StringWrapper)poObject;
			oText.fsText += String.valueOf(piCount);
		}
		recursiveMethod(poObject, piCount + 1);
	}
	static class StringWrapper {
		String fsText = "";
		public StringWrapper(String psText) {
			fsText = psText;
		}
		public String toString() {
			return fsText;
		}
	}
}


can cause big problems if you assume a String is passed by reference Mad
  Send a private message to this user    

SubjectPosterDate
Read Message   Java interview questions... NarkTue, 03 February 2004 09:03
Read Message   Re: Java interview questions...  ehendrikdTue, 03 February 2004 22:50
Read Message   Re: Java interview questions... RobST162Tue, 03 February 2004 22:51
Read Message   Re: Java interview questions... NarkWed, 04 February 2004 00:39
Read Message   Re: Java interview questions... ehendrikdTue, 03 February 2004 22:52
Read Message   Re: Java interview questions... ed_ma61Tue, 03 February 2004 22:59
Read Message   Re: Java interview questions... ehendrikdTue, 03 February 2004 23:51
Read Message   Re: Java interview questions... SIMDOGTue, 03 February 2004 23:55
Read Message   Re: Java interview questions... justcallmefrankWed, 04 February 2004 00:05
Read Message   Re: Java interview questions... ehendrikdWed, 04 February 2004 00:05
Read Message   Re: Java interview questions... ed_ma61Wed, 04 February 2004 00:17
Read Message   Re: Java interview questions... ehendrikdWed, 04 February 2004 00:52
Read Message   Re: Java interview questions... SquidWed, 04 February 2004 01:11
Read Message   Re: Java interview questions... ehendrikdWed, 04 February 2004 01:26
Read Message   Re: Java interview questions... SquidWed, 04 February 2004 01:32
Previous Topic:The Last Hurrah
Next Topic:Super Bowl XXXVIII (has some of the results)

Goto Forum:
-=] Back to Top [=-

Current Time: Sun Nov 24 10:59:35 UTC 2024

Total time taken to generate the page: 0.0073909759521484 seconds

Bandwidth utilization bar

.:: Contact :: Home ::.

Powered by: FUDforum 2.3.8
Copyright ©2001-2003 Advanced Internet Designs Inc.