hi,
See the following piece of code,
int i=1;int j=2;
if(i==1 &| j==2) System.out.println("OK");
How does this compile without error?
Also,
What will happen when you attempt to compile and run the following code?
public class Tux extends Thread{ static
String sName = "vandeleur"; public static void main(String argv[]){ Tux t = new Tux(); t.piggy(sName); System.out.println(sName); } public void piggy(String sName){ sName = sName + " wiggy"; start(); } public void run(){ for(int i=0;i < 4; i++){ sName = sName + " " + i; } }}
1) Compile time error
2) Compilation and output of "vandeleur wiggy"
3) Compilation and output of "vandeleur wiggy 0 1 2 3"
4) Compilation and output of either "vandeleur", "vandeleur 0", "vandeleur 0 1" "vandaleur 0 1 2" or "vandaleur 0 1 2 3"
How does the class instance access the static variable since answer is 4.