Java class by default, it implicitly extends Java lang.Object

See English answers > java doesn't support multiple inheritance but implicitly every class in Java extends object and allows one more

Note: the important statement I've read is that Java enumeration implicitly extends Java Lang. enum class, so your enumeration type cannot extend another class

Note that our ordinary Java class should not extend other classes, such as enum (enumeration type cannot extend another class) But we can inherit a class This is multiple inheritance?

In Java classes, you can derive from the extends keyword like this

class SomeClass
 { }
class MyClass extends SomeClass{}

By default, how do all Java classes extend Java without using the extends keyword in Java Lang. object class?

When our class extends some base classes, it becomes multiple inheritance I searched in stack overflow, but I still don't know By default any class extends Object class. Doesn’t it mean java supports multiple inheritance?

Anyone can clarify this point with a simple example

Solution

>Except Java Except lang. object, each class extends only one class. > If you write extend something, your class extends something. > If you don't write extensions something, your class extends Java lang.Object. (just like the extended object you wrote)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>