+ 1
Can we use polymorphism for a method even if the class is not extending any class
please use a code to make me understand better
3 odpowiedzi
+ 1
but can we do so for a non inheriting class
/* I am talking about methods*/
+ 1
I know, but every class you create has Object as superclass, what you can do is:
Object myClass = new MyClass();
Object myClass1 = new MyClass2();
System.out.println(myClass.toString());
System.out.println(myClass2.toString());
0
Look, in the Tutorial it's mentioned that this is caused by a hierarchy of classes. By the way, every class inherits from Object.