answersLogoWhite

0

this is a reference to the current class

super is a reference to the super class of the current class (the class from which this class extends). You can use super.super if you want to access the second level class. (The class your parent class extends) The purpose of having thisand super keywords is to differentiate between methods and variables in classes that may have the same name as that in the parent class. Under such situations if we want to ensure that only the methods from a particular class only gets called we can use this and super.

User Avatar

Wiki User

17y ago

What else can I help you with?

Continue Learning about Engineering

Is super keyword is analogous to this keyword in java?

No. The keyword super is used to refer to the parent class instance while the keyword this is used to refer to the current class instance. You need to learn about Inheritance and Object creation using constructors to learn more about these keywords and their use


Explain different use of super with the help of java program?

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


How do you prevent method overriding in java?

Use the word "final" directly preceding your method declaration. The presence of final keyword directs java to ensure that, this particular method would not be overridden by any of its child classes.


How constructor called?

You cannot invoke a constructor explicitly. It will get invoked implicitly when you call the new keyword on the class to create an object of the class. Ex: private ClassExample obj = new ClassExample(); here this new keyword usage on the ClassExample class will invoke the constructor of this class and create an object of that class.


How super class variable can be used to refer the sub class object?

The super variable is not a reference to a subclass. It is a reference to the superclass. class MyClass { void printType() { System.out.println("This is a MyClass"); } // MySubClass is a subclass of MyClass. Within this class, the super keyword // refers to MyClass. static class MySubClass extends MyClass { void printType() { // Tell Java we also want to call the printType method of the super class super.printType(); System.out.println("This is a MySubClass"); } } }

Related Questions

Difference between super and this in java?

The keyword super is used to explicitly call methods/values from the parent class The keyword this is used to explicitly call methods/values from the current class


Difference between super and mini computer?

The difference between a super computer and a mini computer is in their computing power. A super computer has infinitely more computing power than a mini computer.


What is the difference between Rhino and Super liner?

The difference is Rhino is a more grippier substance and Super Liner is more plastic.


Is super keyword is anologous to this keyword in java?

No. The keyword super is used to refer to the parent class instance while the keyword this is used to refer to the current class instance. You need to learn about Inheritance and Object creation using constructors to learn more about these keywords and their use


Is super keyword is analogous to this keyword in java?

No. The keyword super is used to refer to the parent class instance while the keyword this is used to refer to the current class instance. You need to learn about Inheritance and Object creation using constructors to learn more about these keywords and their use


What is the difference between super store and mega mart?

A super store has a supermarket. Hense the term "super."


What is the program to use the super and final keyword in java?

Many programs use those keywords.super refers to the direct superclass of the class referencing itfinal declares a variable or class unchangable


What is the difference between a 1973 super beetle and a 1974 super beetle?

The biggest difference is the 74 has energy absorbing bumpers that the 73 is lacking.


Describe the difference between SCR and SCS?

Super Creepy Rituals. Super Creepy Schools.


What is the difference between Super Mario bros and Super Mario world?

super Mario world is a totally different game.


What are some super translations for the keyword "innovation"?

Some synonyms for the keyword "innovation" include creativity, originality, invention, and advancement.


What is the difference between and super bill vs charge slip?

Nothing..

Trending Questions
What is difference between pressure reducing valve and pressure relief valve? How you can do Calibration of voltmeter by potentiometer? Why is pavement always done during the Summer months? What will be the difference in running time of the heap sort algorithm if you start to apply heap sort with an array elements rather than max heap elements? What is the pressure rating of PVC pipe? Write a program to print binary equivalent of given integer value in c? What is the difference between invention and designing? What risks may occur when working with electricity and what is a five step plan to reduce the risk? What does a weighbridge operator do? Selection and Repetition Control Structures Prepare a 3 to4 page paper that addresses the following- Selection Control Structures Explain how selection control structures increase the usefulness and? What process ensures that each daughter cell gets one complete set of genetic information and that each daughter cell has increased surface area? What inventions were made in 1910-1920? Manual system of accounting? What improvments in coal mining were brought about by new technology from 1830-1930? Which of the following can be termed as a good keyword selection and placement strategies? How do you do a motor and gear box alignment using two dial gauge? What is the concept of electrical power and power transfer? What is the abbreviation for WML in HTML? What is the density of reinforced concrete grade 40? Circuit used to convert pwm to ppm?