--%>

"this" pointer is different from a pointer to an object

Q. What is "this" pointer? Explain how is this is different from a pointer to an object?

 

Ans. This: This is variable that refers to the object that has called the member function. This variable is available in all the methods of the class. This is created automatically so we do not need to decide this variable.

 

Example

Class memory

{

Private Int rs;

Private Int paisa;

Public void set (int rs, Int paisa)

{

This. rs = rs;

This . paisa = paisa;

}

Public void set (Int rs, Int paisa)

{

Rs = rs;

Paisa = paisa;

}

*/

Note: If we comment out this x has been and put restriction on code y to execute, there will be default value in the field. if we create an object of this money class outside the money then, this pointer exists in that particular class only and a pointer to an object can exist in outside classes also. 

   Related Questions in Programming Languages

  • Q : Perform Exception Handling with

    On occasion, some of Brewbean’s customers mistakenly leave an item out of a basket already checked out, therefore they create a new basket containing the missing items. Though they request that the baskets be combined and hence they are not charged extra shippin

  • Q : Reads a line of text and tests whether

    palindrome.asm -- reads a line of text and tests whether it is a palindrome. ## Register usage: ## $t1 - A. ## $t2 - B. ## $t3 - the character *A. ## $t4 - the character *B. ## $v0 - syscall parameter / return values. ## $a0 - s

  • Q : Define Checked exception Checked

    Checked exception: An exception which should be caught locally in the try statement, or propagated through a throws clause stated in the method header.

  • Q : Explain Structured programming

    Structured programming: It is a style of programming generally related with languages like FORTRAN, C, Pascal and so forth. Employing structured programming methods, a problem is frequently resolved employing a divide and conquer approach like stepwis

  • Q : State HyperText Transfer Protocol

    HyperText Transfer Protocol: The HyperText Transfer Protocol (abbreviated as HTTP) is a set of rules stated to enable a Web client (that is, browser) to interact with the Web server.

  • Q : Define Bounds Bounds : It is the limits

    Bounds: It is the limits of an array or collection. In Java, the lower limit is for all time zero (0). In case of an array, the upper bound is one less than the length of the array, and is fixed. Indexing exterior the bounds of an array or collection

  • Q : Explain Virtual memory Virtual memory :

    Virtual memory: It is computer will comprise a limited amount of real memory accessible to it. Programs frequently need more memory than the quantity of real memory. Moreover, in a multiprogramming system, various processes will be competing for simil

  • Q : What is Application programming

    Application programming interface (API): It is a set of definitions that you can make use of it in writing programs. In the perspective of Java, these are the classes, packages, and interfaces which can be utilized to build complex ap

  • Q : Define the term Address space Define

    Define the term Address space: The region of virtual memory in which a procedure is run.

  • Q : Explain the important thing to HTML

    Explain the important thing to HTML document authors.