How are this and super used?

Answer Posted / kabita

'this' and super are two keywords in java.
'this' doesn't support inheritance bt 'super' supports
inheritance.
this keyword is used in two cases
1.to differentiate betn instance and local variables.
2.calling of one constructor from another constructor.
Restriction:this keyword should be written in lowercase &
must used in firstline.more than one 'this' keyword is not
used in one block.
super is used 4 three reason.
1.differentiates betn superclass variable & child class
variables.
2.calling of superclass constructor in childclass
constructor.
3.it is also used in calling of superclass override method
in child class.
restriction:
it must be in 1stline.
must be in lowercase.

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a layout manager and what are different types of layout managers available in java awt?

704


What is a ternary operator in java? What is an interface?

538


What is the argument in java?

479


How do you avoid global variables?

531


What is an empty class? What functionality does it offer in Java?

662






Can we use switch statement with strings?

607


Can It is possible to synchronize the constructor of a Java Class?

585


Can we have static methods in an interface?

542


What about static nested classes in java?

575


Are true and false keywords?

554


Is string is a class in java?

511


What are the important methods of java exception class?

558


What is the importance of main method in Java?

561


What is thread life cycle in java?

570


What is treeset in java?

528