I have googled couple of times but still can't understand the supertype method. Can anyone please explain what is this?
There is a notion of supertype and subtype in OOPS, In java this kind of relationship is implemented by inheritance i.e. using extends
keyword:
class A {} // super class
class B extends A {} //sub class
Any member (fields, methods) declared in super class is to be called supertype.
Therefore in above context if class A
has method like
class A {
void set()
}
Set is supertype method for class B
.
However, notice that if there is another class say C
:
class C {
void set()
}
Then set()
method is not supertype for C
class because there is no relationship between class A
and class C
(relationship is created by extends
keyword, for inheritance).
if you are talking about calling a super method, you should try the following
printSomething()
public void printSomething() {
System.out.println("hello, I am the first class");
}
@override
public void printSomething() {
super.printSomething();
}
printSomething
of class two and see what will happenIf you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With