Answer:
By using the this keyword
Explanation:
The this keyword in java is used for pointing the current object or current variable .The this keyword is removing the ambiguity among the characteristics of the class as well as the variables with the similar name.
In the given question if the class student has member variable gpa also we have a method having the argument gpa with the help of this keyword we can refer the gpa variable inside the method .
Following are the implementation of the given question
public class Main // main class
{
int gpa; // variable declaration
public Main(int gpa) // constructor
{
this.gpa = gpa; // this keyword
}
public static void main(String[] args) // Main method
{
Main m= new Main(55); // creating object of class
System.out.println("The Value of gpa is : " + m.gpa); // display value
}
}
Output:
The Value of gpa is :55