Leave a Reply 2

Your email address will not be published. Required fields are marked *


renko

renko

Code question:

public class Test {
public static void main(String[] args) {
Test ts = new Test();
System.out.print(isAvailable + ” “);
isAvailable = ts.doStuff();
System.out.println(isAvailable);
}
public static boolean doStuff() {
return !isASvailable;
}
static boolean isAvailable = false;
}

Output:
Exception in thread “main” java.lang.RuntimeException: Uncompilable source code – cannot find symbol
symbol: variable isASvailable
location: class Test
at Test.doStuff(Test.java:10)
at Test.main(Test.java:6)
false

renko

renko

Typo: return !isASvailable; => return !isAvailable;

Output:
false true

Answer: C