"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 : Explain State State : The objects are

    State: The objects are said to possess state. The present state of an object is symbolized by the joint values of its attributes. Protecting the state of an object from unsuitable inspection or modification is a significant aspect of class design and

  • Q : Explain main quality of unsuitable life

    What are the main quality consequences of selecting an unsuitable life cycle model for a software project?

  • Q : Advantage of wrapping database calls in

    What is the advantage of wrapping database calls in MTS transactions?

  • Q : Explain relationship between XHTML and

    Explain relationship between XHTML and DTD?

  • Q : Requirement of Timer control in AJAX

    Explain the requirement of a Timer control in the AJAX.

  • Q : Define Daemon thread Daemon thread :

    Daemon thread: The daemon threads are non-user threads. They are usually employed to carry out low-priority tasks which must not take priority over the major task of the program. They can be employed to do helpful work whenever all other user threads

  • Q : Define Data type Data type : There are

    Data type: There are 8 primitive data types in Java; five of such symbolize numerical types of changeable range and precision - float, double, int, long and short. The remaining three are employed to symbolizing single-bit values (that is, Boolean), s

  • Q : Which kernel objects is utilize for

    Which kernel objects is utilize for thread Synchronization on various processes? Answer: For thread synchronization on various processes kernel objects are utilize

  • Q : State the term WSDL State the term WSDL

    State the term WSDL?

  • Q : Define Property Specifications Property

    Property Specifications: Users can specify assertions using the assert(expr) statements. An assert statement is used to check if the property specified by the expression expr is valid within a state. If expr evaluates to 0, this implies that it is not

©TutorsGlobe All rights reserved 2022-2023.