close

一.題目

Given:

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

image

 

 

 

arrow
arrow
    創作者介紹
    創作者 書童 的頭像
    書童

    小書童

    書童 發表在 痞客邦 留言(0) 人氣()