in Education by
This method is in a Scores class, that is set the class variable scores, but the scores is combination of its sub class, for example, scores = sub scores1 + sub scores2, sub1/sub2 is calculated by the subclasses of Scores. public void setScores (double scores) { this.scores = scores; } public void calculateScore(double sub1, double sub2) { this.scores = (sub1 + sub2) /2; } is there method/design skills/practice to constraint the class can't alter the scores value (i.e run the setScores), after the calculateScore() just ran. JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Get rid of both methods, and implement final double getScores(double sub1, double sub2) to do the calculation, and return the required result.

Related questions

0 votes
    This method is in a Scores class, that is set the class variable scores, but the scores is combination ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 10, 2022 in Education by JackTerrance
0 votes
    This method is in a Scores class, that is set the class variable scores, but the scores is combination ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 7, 2022 in Education by JackTerrance
0 votes
    This method is in a Scores class, that is set the class variable scores, but the scores is combination ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    If super class and subclass have same variable name, which keyword should be used to use super class? ( ... questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    Constraint checking can be disabled in existing _______________ and _____________ constraints so that any data you ... Interview Questions and Answers for Freshers and Experience...
asked Oct 11, 2021 in Education by JackTerrance
0 votes
    We have a requirement for a dexterity content type to have exclude from navigation behaviour but for the ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I am currently using a LINQ query to read an XML file e.g. some_text some_more_text into a list ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 15, 2022 in Education by JackTerrance
0 votes
    Which of these keywords is used to refer to member of base class from a subclass? (a) upper (b) ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 26, 2021 in Education by JackTerrance
0 votes
    A class member declared protected becomes a member of subclass of which type? (a) public member (b) ... questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    A class member declared protected becomes a member of subclass of which type? (a) public member (b) ... questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    In order to restrict a variable of a class from inheriting to subclass, how variable should be declared? ( ... questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    Which of the following is a super class of all exception type classes? (a) Catchable (b) RuntimeExceptions (c ... Handling of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Which of these is a super class of all exceptional type classes? (a) String (b) RuntimeExceptions (c) ... Exception Handling of Java Select the correct answer from above options...
asked Mar 1, 2022 in Education by JackTerrance
0 votes
    Which of these class is super class of all the events? (a) EventObject (b) EventClass (c) ActionEvent (d) ... Event Handling of Java Select the correct answer from above options...
asked Feb 24, 2022 in Education by JackTerrance
0 votes
    Which of these is a super class of wrappers Double & Integer? (a) Long (b) Digits (c) Float ( ... java programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
...