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
Anni [7]
3 years ago
12

Modify the following class so that the two instance variables are private and there is a getter method and a setter method for e

ach instance variable:
public class Player {
String name;
int score;
}
Computers and Technology
1 answer:
Gnoma [55]3 years ago
3 0

Answer:

The program to this question can be given as follows:

Program:

class player//defining class player

{

//defining variable name and score.

String name;

int score;

String get_Name() //defining method get_Name

{

return name; //return value.

}

void set_Name(String name) //defining method set_Name

{

//using this keyword to hold variable value

this.name = name; //hold value

}

int get_Score() //defining method get_Score

{

return score; //return value

}

void set_Score(int score) //defining method set_Score

{

//using this keyword to hold variable value

this.score = score; //return value

}

}

public class Main //defining class Main

{

public static void main (String[] args) //defining main method

{

//defining variable

int x;

String n;

player ob= new player(); //creating player class Object

ob.set_Name("data"); //calling function set_Name and pass the value.

ob.set_Score(10); //calling function set_Score and pass the value.

n=ob.get_Name(); //holding value

x=ob.get_Score();//holding value

System.out.println(n+"\n"+x); //print value.

}

}

Output:

data

10

Explanation:

In the above java program, the class player is defined, which contains two-variable "name and score" in which the name is a string type and score is an integer type.

  • In the next line, the getter and setter method is used, which is set is used to set the values and get is used to return the values.
  • Then the Main class is declared inside the class the main method is defined that creates a player class object and call the function.
You might be interested in
You have an interface on a router with the ip address in the class c network subnet of 192.168.192.10/29. how many total host ad
Gemiola [76]
If 29 bits of the 32 available addressing bits are used for the subnet, then only 3 bits giving 2^3=8 combinations remain for the host addresses. 

In reality, the all zeros and all ones addresses are reserved. So, 8 addresses can exist, but 6 of those are available.

The way the question is formulated it seems the answer 8 is what they're after.
8 0
4 years ago
When Mary started college, her parents bought her a new computer that came loaded with the bare essentials in terms of software
Darina [25.2K]

Answer:

office online

Explanation:

office online is a free online version of Microsoft office suite. it includes Microsoft word, Microsoft excel,  Microsoft power point, one note. It allows users to create and edit files online.

5 0
4 years ago
The ____________ is an efficient method to mount, power, and organize electrical motor control, automation, and power distributi
Lesechka [4]

Answer:

Motor Control Center

Explanation:

Such centers are built to control various or all (if possible) electric motors found in a central location. The Motor Control Center usually comprises of many section that are enclosed but having one central power bus, but each of the section would have its own combination starter. It is an efficient power distribution system also.

4 0
3 years ago
Help! I turned on my computer and this screen came on out of nowhere, I don't know what to do to fix it.
babunello [35]

Here are the steps I would do:

Do a "hard" power off. Hold the power key until the screen turns off. Wait 10 seconds. Turn it on. If it still shows the screen... then i'm not sure.

The error is occurring because it has nothing to boot off of. It's probably something wrong with your hardware. The instructions say for you to insert a "boot disk" and press any key.

4 0
3 years ago
Read 2 more answers
This is Computer Literacy
vladimir1956 [14]
Your answer is True.

If this answer is incorrect, then i am sorry.
7 0
4 years ago
Other questions:
  • What is the Multiplier if the change in RGDP is $525,000,000 and initial spending is $100,000?
    12·1 answer
  • If you want an app to reach the largest possible audience, which two platforms should you use?
    7·1 answer
  • When you first start your computer, which software will have to start first?
    5·2 answers
  • You play guitar and keep two files on your computer. One file, called strings, lists the different brands of strings you keep on
    8·1 answer
  • What is the name of the symbol that is used to classify and categorize information?​
    10·2 answers
  • The following code processes a file containing five positive numbers. What will the variable $result contain after the code is e
    10·1 answer
  • What is the value of 8n when n= = 2?​
    13·1 answer
  • Where is the BIOS stored?<br><br> CPU<br> CMOS<br> RAM<br> Northbridge
    13·2 answers
  • Which option identifies the programming paradigm selected in thr following scenario? A student is writing a science fiction stor
    12·1 answer
  • What is boot sector virus​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!