Ask Question

An instance variable name of type String, initialized to the empty String. An instance variable score of type int, initialized to zero. A method called setName that has one parameter, whose value it assigns to the instance variable name. A method called setScore that has one parameter, whose value it assigns to the instance variable score. A method called getName that has no parameters and that returns the value of the instance variable name. A method called getScore that has no parameters and that returns the value of the instance variable score.

+2
Answers (1)
  1. 19 March, 04:00
    0
    public class Class {

    private String name = "";

    private int score = 0;

    //Method SetName

    public void setName (String newName) {

    name = newName;

    }

    //Method SetScore

    public void setScore (int newScore) {

    score = newScore;

    }

    //Method GetName

    public String getName () {

    return name;

    }

    //Method GetScore

    public int getScore () {

    return score;

    }

    }

    Explanation:

    The class called Class is implemented in Java programming language It has two fields (instance variables name and score) Methods for setting the values of variables (mutator methods) or setters Methods for getting the values of the variables (accessor methods) getters
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “An instance variable name of type String, initialized to the empty String. An instance variable score of type int, initialized to zero. A ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers