I have googled couple of times but still can't understand the supertype method. Can anyone please explain what is this?
相关问题
- Delete Messages from a Topic in Apache Kafka
- how to define constructor for Python's new Nam
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
if you are talking about calling a super method, you should try the following
create a class with a method public method e.g. printSomething()
public void printSomething() { System.out.println("hello, I am the first class"); }
create a second class which inherites from the first class and override the printSomething method
@override public void printSomething() { super.printSomething(); }
write a small programm which call the method printSomething of class two and see what will happen
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:Any member (fields, methods) declared in super class is to be called supertype.
Therefore in above context if class
A
has method likeSet is supertype method for class
B
.However, notice that if there is another class say
C
:Then
set()
method is not supertype forC
class because there is no relationship between classA
and classC
(relationship is created byextends
keyword, for inheritance).Super at Constructer level
Super Type and sub type is a property of inheritance i.e for the purpose of re-usability of code. I am giving you example of Super Class and Sub class. For more you can follow here.
using System;
enter image description here
In java every thing are object and a method is also a object of class java.lang.reflect.Method So the super type of method can be consider as the super class of
java.lang.reflect.Method
that is theAccessibleObject
.Super is used to invoke parent class Properties used at 3 levels variable constructer and method level
1.Super at Variable