Fault的定义:可能导致系统或功能失效的异常条件(Abnormal condition that can cause an element or an item to fail.),可译为“故障”。
Error的定义:计算、观察或测量值或条件,与真实、规定或理论上正确的值或条件之间的差异(Discrepancy between a computed, observed or measured value or condition and the true, specified, or theoretically correct value or condition.),可译为“错误”。Error是能够导致系统出现Failure的系统内部状态。
Failure的定义:当一个系统不能执行所要求的功能时,即为Failure,可译为“失效”。(Termination of the ability of an element or an item to perform a function as required.)
第一个程序:

错误是for(int i =x.length-1;i>0;i--)
因为i>0,所以无法检验x[0]是否与y相等,应该改为i>=0
不执行错误:Text:x=null
执行错误,但结果不出现错误:Text:x=[1,2,3] y=2
结果错误,但不是failure:Text:x=[1] y=2
第二个程序:

错误是循环的方向与设想的不符,应该改为for (int i=x.length-1; i >= 0; i--)。
不执行错误:因为该程序从前往后执行,因此没有不执行fault的情况
执行错误,但结果不出现错误:Text:x=[0]
结果错误,但不是failure:Text:x=[0,1]因为只有一个0因此不会出现failure但是返回的却是第一个0,因此是error
homework2
原文:http://www.cnblogs.com/u1114401/p/6476926.html