close
一.題目
Given:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cart{ | |
Product p; | |
double totalAmount; | |
} | |
class Product{ | |
String name; | |
Double p; | |
} | |
public class OCA_7 { | |
public static void main(String[] args) { | |
Cart c = new Cart(); | |
System.out.println(c.p + ":" + c.totalAmount); | |
} | |
} |
What is the result?
A. null:null:0.0
B. null:null
C. <HashCode>:0.0
D. null:0.0
二.答案
D
三.解析
物件的預設值是 null,double的預設值是0.0。
型態 |
預設值 |
boolean |
false |
byte |
0 |
int |
0 |
long |
0 |
double |
0.0 |
一般物件型態 |
null |
String |
null |
文章標籤
全站熱搜