Computers and Technology
17.08.2022 09:05
211
473
9
Solved by an expert

g If a class named Student has a data member named gpa , and one of its member functions

g If a class named Student has a data member named gpa , and one of its member functions has a parameter also named gpa , how can you refer to the data member inside that member function
Show Answers
ladnerhailey16
ladnerhailey16
4,4(65 marks)

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

oliwia0765
oliwia0765
4,6(51 marks)
I believe you would use more energy sources other than fossil fuels. Driving more would definitely not help it, and I'm pretty sure it's not the last answer choice. :) Hope this helps. 

Popular Questions about the subject: Computers and Technology

What are the elements of an autobiographical narrative similar to those...
Computers and Technology
29.10.2020 09:25
In windows vista, which button is used to create a new folder? a. organize...
Computers and Technology
17.02.2022 22:17
Write the definitions of the functions to overload the assignment operator...
Computers and Technology
19.09.2021 08:06
Consider the following problem: You are given a pointer to the root...
Computers and Technology
02.07.2020 16:14
Which of the following is not affected by the expectations and attitudes...
Computers and Technology
25.01.2020 15:04
Select the correct answer. Which action does file compression perform?...
Computers and Technology
31.03.2023 09:43
I mistakenly charged my phone overnight and its not working i cant...
Computers and Technology
07.02.2021 12:08
Which one of these cannot be used to insert data into Excel?...
Computers and Technology
08.05.2022 18:17
What is the use of numeric variable list any two numeric variable...
Computers and Technology
23.11.2021 04:38

New questions by subject

Two activities of the cell membrane are and...
Chemistry
06.10.2022 04:08
Which of the following would be a reason why people save and invest...
Social Studies
09.04.2023 04:12
All perfect numbers are even numbers, true or false? , i really need...
Mathematics
16.05.2021 15:30
Describe why index fossils are useful to geologists...
Biology
23.09.2021 11:55
Describe why index fossils are useful to geologists...
Biology
13.06.2020 00:04
If a liquid is heated and the temperature at which it boils is measured,...
Chemistry
02.02.2022 04:38
Which point is a reflection of point p across the x-axis? point ?...
Mathematics
08.01.2023 09:04
The custom of finding a button is the plum pudding means what to an...
English
05.10.2022 02:33
#
#
#
#
# #

We expand our knowledge with many expert answers