answersLogoWhite

0


Best Answer

the keyword super is used to access methods/variables of the parent class.

ex:

public class A {

public String getName(){

.....

}

}

public class B extends A {

public String getName(){

.....

}

}

If you want to access the method getName of class A inside class B you cannot do directly because the compiler would get confused. you need not create an object of A since it is already available. At this point you can use super

super.getName() is enough to call the method of the parent class

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

Super is usually used to explicitly call methods of the parent class. There maybe cases where a child class & parent class have methods of the same name. If we just mention the method name, the child class method only would be called. So to explicitly call the parent class method we would use super.

Example:

Lets assume class A has a method getName();

public class B extends A {

public String getName(){

}

public void xxx(){

String xyz = super.getName();

}

}

by using super we are explicitly calling the method in the parent class A

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

The super keyword is used to call variables, methods, and/or constructors of a parent class. If references the parent class through the super keyword (super.[field] or super.[method/constructor]([args])).

The final keyword has a few uses.

  1. The most common is to make a variable's value constant, and create a compile error if it is changed after its first assignment of a value. This does not mean that the variable is immutable: the value itself can possibly change, but the assignment to that value cannot.
  2. A method declared final cannot be changed in a subclass.
  3. A final class cannot be subclassed.
This answer is:
User Avatar

User Avatar

Wiki User

14y ago

They keyword super is used in the Java programming language when we use Inheritance. Let us say a class A extends another class B and it needs to invoke a certain method in the parent class it can do so by:

super.method();

The keyword super can be stacked up one on top of another to access multiple layers of parent classes.

super.super.method() will invoke the method in the class that is the parent class of the current class's parent class. Second level.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Explain different use of super with the help of java program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Explain with help of an an example how FAT different from inode?

explain with help of an example, how FAT is different from inode.


Explain how designers use different construction features to help the user access information on websites?

Explain how designers use different construction features to help the user access information on websites


How the different health program and services help in the mortality decline?

hi can u help me???


Do you have to be a supervisor to join the mentoring program?

The Mentoring Program was established to help new Supervisors learn to use their new Super Powers, and to learn about the Super Community, but you don't have to be a Supervisor to ask a Mentor for help. All Mentors are ready and willing to help contributors and Supervisors alike when a problem comes up, or if they need help in any way.


What different between crocodile and super crock?

help i dont know the question


What do you mean by GUI and Explain different GUI technology with help of example?

Graphical User Interface


Why do cars have different tires on different terrains?

Friction and the way the tires grip the terrain help to explain why there are varied types of tires.


Explain how sentences and clauses work at the most basic level Discuss how clauses make up sentences and how different sentences can help you communicate?

Explain how sentences and clauses work at the most basic level. Discuss how clauses make up sentences and how different sentences can help you communicate Explain how sentences and clauses work at the most basic level. Discuss how clauses make up sentences and how different sentences can help you communicate


What are different works that help explain the fairness of someone's skin?

The different words that are used to explain the fairness of someone's skin are white, fair, bloodless, pallid, rosy, pasty, sallow, and peaches-and-cream.


What are the uses of super magnets?

Super magnets are used to help produce sound in speakers. They also help pick up vibrations in electric and bass guitars. These magnets come in many different forms.


How can you help prejudiced people?

the best ting to do is just explain to them that there are different groups of people and just because they are different, does not mean they are bad people.


Where can I find help with program management online?

There are many different websites online that have information on program management. Wikipedia has some information on program management. Managementhelp.org is another helpful website.