1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
NikAS [45]
3 years ago
7

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 ca

n you refer to the data member inside that member function
Computers and Technology
1 answer:
victus00 [196]3 years ago
5 0

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

You might be interested in
What is cpu????????????????????????????
Paul [167]

Answer:

CPU

Explanation:

CENTRAL

PROCESSING

UNIT

8 0
3 years ago
Read 2 more answers
Which factor did not contribute to the increase of leisure travel in the early twentieth century in the United States?
Vitek1552 [10]
The second factor as it did not make travel easy at all
6 0
3 years ago
Read 2 more answers
How to get an object from a container in java.
Vinil7 [7]
If it stores any type of objects mixed, use Object as storage class. All classes inherit from Object and for primitives use their respective wrapper classes. Or just use one of the bazillion container classes that already exist.
3 0
2 years ago
Which key(s) will launch the Spelling Checker dialog box? F8 F7 Ctrl+H F2
KIM [24]

Answer:

F7

Explanation:

Mostly in MS Office products, although a lot of other products will mimic the same well known key sequences as a way of enticing you to their platform.

6 0
2 years ago
Read 2 more answers
2. When a business practices offensive behavior, you have many options. The option with the loudest voice is
Andreas93 [3]
—-_-__-____- _—-_- -__-_-____-__




___-_-_ _- —|
4 0
2 years ago
Other questions:
  • A(n ____ is anything about which data are to be collected and stored.
    8·1 answer
  • Write a function called first_last that takes a single parameter, seq, a sequence. first_last should return a tuple of length 2,wh
    14·1 answer
  • How to wire two separate switches & lights using the same power source?
    14·1 answer
  • When searching the web software programs called fetch a few web pages and then they follow the links on those pages and fetch th
    9·2 answers
  • What is a wiki farm?
    9·1 answer
  • Elizabeth works for a local restaurant at the end of her shift she read she’s required to write in the time that she arrived in
    14·1 answer
  • A representation of something by using a description, summary or image.
    7·1 answer
  • Discuss, in detail, the usefulness of graphics and images in program development. Explain the importance of the interface of a c
    7·1 answer
  • Drag each statement to the correct location.
    10·1 answer
  • you are investigating the use of website and url content filtering to prevent users from visiting certain websites. which benefi
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!