what is the function of 'this' operator ?

Answer Posted / venkat

'this' is used to reffer current class variable

for example

class sample
{

int myvar=10;
void mymethod()
{
int myvar=20;
system.outprintln("The value of myvar is"+myvar)
system.outprintln("The value of myvar is"+this.myvar)
}
}


output :
20,10

Is This Answer Correct ?    39 Yes 15 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is class encapsulation?

604


Which language is not a true object oriented programming language?

646


Which language is pure oop?

553


Can main method override?

587


Why is encapsulation used?

579






Why do while loop is used?

579


What is object in oop with example?

707


What is ambiguity in inheritance?

626


How to handle exception in c++, For example in a functions i am assigning memory to some variables and also in next instructions in am dividing one variable also. If this functions generates a error while allocating memory to those variable and also while dividing the variable if i divide by zero then catch block how it will identify that this error has cone from perticular instruction

1657


Describe these concepts: Polymorphism, Inheritance and Abstraction.

616


How do you achieve runtime polymorphism?

573


What are the benefits of oop?

607


What is difference between oop and pop?

620


What is polymorphism what are the different types of polymorphism?

566


What is abstraction in oop?

640