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 use of valueof () in java?

555


Difference between serialization and deserialization in java?

650


Is a method a function?

548


Can constructor be static or final?

649


What is the use of singleton class?

519






What are different access specifiers in java? Explain

628


What's the default access specifier for variables and methods of a class?

512


What will happen if a thrown exception is not handled?

561


Which number is denoted by leading 0x or 0x in java?

562


In java, what is the difference between method overloading and method overriding?

581


Is ruby built on java?

529


What is time complexity java?

534


Why isn’t there operator overloading?

592


What is main string [] args?

520


What is abstraction in java?

615