Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does super() method do?

Tags:

What does the super method do?

public DataFetch(Context context) {     super();     this.ctx = context; } 

Does this constructor make the context of the newly created object the context of the super class? Not 100% sure how this works. So would the super() method essentially just be saying "put me into super class mode" to say it in lay man's terms?

like image 259
mergesort Avatar asked May 25 '11 01:05

mergesort


People also ask

What is the super () method used for?

Definition and Usage The super() function is used to give access to methods and properties of a parent or sibling class. The super() function returns an object that represents the parent class.

How does super () work in Java?

The super keyword in Java is a reference variable that is used to refer parent class objects. The super() in Java is a reference variable that is used to refer parent class constructors. super can be used to call parent class' variables and methods. super() can be used to call parent class' constructors only.

How does super () work Python?

The super() function in Python makes class inheritance more manageable and extensible. The function returns a temporary object that allows reference to a parent class by the keyword super. The super() function has two major use cases: To avoid the usage of the super (parent) class explicitly.

What does super () return in Python?

super() returns a delegate object to a parent class, so you call the method you want directly on it: super().


1 Answers

It says "initialize my parent class before you initialize me" by calling its default constructor.

like image 96
duffymo Avatar answered Sep 19 '22 07:09

duffymo