I went on an interview last week and was thrown this question:

what is wrong/sub-optimal with the following code:

public class someClass {
/*
* some methods, etc
*/
public boolean myBool = false;
}

Of course, since booleans default to false, it would be "better" to code as:
public boolean myBool;

However, I answered that I would choose the original version as it was
clearer to read, and trust the compiler to optimize this.

The interesting thing is that I then tested this at home and created 2
identical java classes to test this.  One with:
public boolean myBool = false;
and one with:
public boolean myBool;

To my surprise the class file sizes were different.  However, given that
they only differed by this one statement, I would not have expected this.

Can anyone comment on why this is please?
Do other 'commercial' compilers/compilers on other os's have the same
issues?
Does anyone know of other compiler inefficies like this?

Thanks,
Dave Blankley.

Side Note:
The test was run on Suse 6.1 with blackdown java 1.2.2.

........................................................ 
iWon.com       http://www.iwon.com     why wouldn't you? 
........................................................


----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to