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
Solution(By Examveda Team)
By default, a boolean variable will contain false.Join The Discussion
Comments ( 8 )
Related Questions on Data Types and Variables
What is the maximum value that can be stored in a byte variable in Java?
A. 127
B. 255
C. 32767
D. 64
What is the default value of an int variable in Java if it's not explicitly initialized?
A. 0
B. 1
C. -1
D. Null
Which of the following is not a valid identifier for a Java variable?
A. my_var
B. _myVar
C. 3rdVar
D. $var
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.