The following program:
public class Test{
static boolean isOK;
public static void main(String args[]){
System.out.print(isOK);
}
}
public class Test{
static boolean isOK;
public static void main(String args[]){
System.out.print(isOK);
}
}
A. Prints true
B. Prints false
C. Will not compile as boolean is not initialized
D. Will not compile as boolean can never be static
Answer: Option B
May be in boolean 1)true =true
2) istrue = false
How can it be FALSE, can someone explain?
by default, a boolean variable will contain false.
static boolean isOK;
static variables gets always get initialized with some values and because this is BOOLEAN TYPE hence default initialization value=FALSE
boolean datatype always set its initial valuue as false
By default value of isok is false(i.e value of boolean var is false)
i don't understand..please explain it..
Please Explain it.