Given:



public class FieldInit {

    char c;
    boolean b;
    float f;

    void printAll() {
        System.out.println("c = " + c);
        System.out.println("c = " + b);
        System.out.println("c = " + f);
    }

    public static void main(String[] args) {
        FieldInit f = new FieldInit();
        f.printAll();
    }
}

What is the result?

A.

c = null
b = false
f = 0.0F

B.

c = 0
b = false
f = 0.0f

C.

c = null
b = true
f = 0.0

D.

c =
b = false
f = 0.0

題解

類別或是物件的欄位,字元型態的初始值為「'\0'」(字元值為0),數值型態的初始值為「0」,布林型態的初始值為「false」,物件型態的初始值為「null」。