5 可以There's no method that tune () could call for an Instrument that isn't also in Wind

The tune ( ) method accepts an Instrument reference. However, in Wind.main() the tune() method is handed a Wind reference. Given that Java is particular about type checking, it seems strange that a method that accepts one type will readily accept another type, until you realize that a Wind object is also an Instrument object, and there's no method that tune could call for an Instrument that isn't also in Wind.

这是更完整一点的段落。内容是关于编程的,其中"tune()"表示一个内中的方法,可以被调用。InstrumentWind是一个示例类,可以把他们当作"A""B"或者"xxx"处理

请先 登录 后评论

1 个回答

huck finn   - 语言学爱好者
擅长:语言学

There's no method that tune () could call for an Instrument that isn't also in Wind.

There's no method 【主句】

that tune () could call for an Instrument 【定语从句1,先行词为method

that isn't also in Wind 【定语从句2,先行词为method+定语从句1

【先行词+定语从句1+定语从句2这种定语从句结构称为双重定语从句。

译文尝试将no ... isn't双重否定翻译为肯定,仅供参考:

tune()接收Instrument类的对象调用的方法一定也能通过接收Wind类的对象进行调用。

也就是说,因为Wind类继承了Instrument类,往tune()中传入Wind类的对象,会向上转型为Instrument类,所以tune方法也能接收Wind类的对象。

以下是一些相关单词解释:

instrument乐器,wind管乐器,flute笛子,play演奏,tune调音。

请先 登录 后评论
  • 1 关注
  • 0 收藏,1182 浏览
  • Arnold Li 提出于 2022-07-12 14:29