Given:



What would be the output, if it is executed as a program?

A.

name =, pass =

B.

name = null, pass = null

C.

name = null, pass = false

D.

name = null pass = true

E. Compile error.

題解

Java的類別或是物件欄位會按照不同資料型態自動給定初始值。初始值如下:

String、Object:null
byte、short、int、long、float、double:0
char:\0
boolean:false