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

Define Multiprogramming and Multiprocessing in java.

586


How do you use parseint in java?

515


What are keywords in programming?

570


What does it mean to be immutable?

552


Is java a virus?

536






How are java objects passed to a method and what are native methods?

602


What are the types of methodology?

518


What is identifier give example?

561


What are encapsulation, inheritance and polymorphism?

531


What is predicate in java?

562


What is autoboxing and unboxing?

589


How to find the index of the largest number in an arraylist java?

522


What is a generic data type?

574


Can we clone singleton object in java?

575


What is constant in programming?

560