is System.in an object reference of InputStream class?

后端 未结 3 957
不知归路
不知归路 2021-01-16 16:38

InputStream is an Abstract class.Then how are we able to access System.in.And moreover int read() is an abstract method in InputStream class.Then how are we able to access S

3条回答
  •  太阳男子
    2021-01-16 17:15

    I suggest you to read more about abstraction and inheritance methods in Java.

    If you extend an abstract class, you have to implement its abstract methods. This way, you provide an implementation for it, which can be called by consumers.

    System.in is an instance of a class which extends InputStream, not of InputStream directly.

提交回复
热议问题