Saturday, 8 August 2009

Java Certification Question 0058

What will happen when you attempt to compile and run the following code.

public class Pvf{

static boolean Paddy;

public static void main(String argv[]){

System.out.println(Paddy);

}

}

1) Compile time error
2) compilation and output of false
3) compilation and output of true
4) compilation and output of null


Answer 2:

2) compilation and output of false

A variable defined at class level will always be given a default value and the default value for the primitive type boolean is false

No comments: