---
# System prepended metadata

title: 介面 interface 延伸
tags: [ocpjp]

---

# 介面 interface 延伸
介面可以多重繼承

```java=
interface 子介面名稱 extends 父介面1名稱,父介面2名稱,...
{
  ...
}
```

Example:
```java=
interface Downloadable{
	public void download();
}
interface Readable extends Downloadable{ //line n1
	public void readBook();
}
abstract class Book implements Readable{ //line n2
	public void readBook() {
		System.out.println("Read Book");
	}
}
class Ebook extends Book{ // line n3
	public void readBook() {
		System.out.println("Read E-Book");
	}
}
```
## What is the result?
A. Compilation fails at line n2.
B. Read E-Book
C. Compilation fails at line n1.
**D. Compilation fails at line n3.**
E. Read Book
- [x] **Answer: D**

:::info
因為Book implements Readable
Readable extends Downloadable
所以還有public void download()需要實作
:::

###### tags: `ocpjp`