"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.



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 : Explain Base type Base type : The kind

    Base type: The kind of items that might be stored in an array - the arrays defined type. For example, in     int[] numbers; the base type

  • Q : Interface accessibility modifier Inside

    Inside the interface accessibility modifier we can use for methods?

  • Q : Explain Return statement Return

    Return statement: It is a statement employed to terminate the execution of the method. The method with void return type might only have return statements of the form as: return;

  • Q : Database management information system

    How much would it cost to create a simple database management information system by utilizing MySQL and PHP?The proposal of the system should include the following: Background narrative of setting and background of problem m

  • Q : Explain Counters Counter variables are

    Counter variables are commonly used in many computer applications for different purposes. Here is a typical example where a variable is used to measures the progress of some activity of interest:

    Q : Define Number of Threads Number of

    Number of Threads: Threads can be a useful abstraction and implementation mechanism to partition independent program actions. However, when there is coordination (or interference) between these threads, the required synchronization mechanisms increase

  • Q : What is Java What is Java: It is a

    What is Java: It is a portable high level programming language introduced by Sun Microsystems.

  • Q : Define Function Function : The name

    Function: The name given to assembly of statements which does some particular task and might return a value. Function can be invoked (or called) any number of time and anywhere in the program.

  • Q : What is the use of compatibility testing

    What is the use of compatibility testing?

  • Q : Explain different types of variable iv

    The kind of value that a variable can own is known as data type. When we state a variable we require specifying the type of value it will own with the n

©TutorsGlobe All rights reserved 2022-2023.