Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 7 Given a class Spaceship with private field numYears and method: publi

ID: 3732576 • Letter: Q

Question

Question 7 Given a class Spaceship with private field numYears and method: public void addNumYears (int numYears) ,answer to the following questions: 1. In addNumYears , which would set field numYears to 0? numYears = 0; . this (numYears)0 . this.numYears=0; 2. In addNumYears, which would assign the parameter numYears to the field numYears numYears = this.numYears; this.numYears numYears: 3. In addNumYears(), which would add the parameter numYears to the existing value of field numYears? . this.numYears-this.numYears numYears: this.numYears = numYears + numYears; Not possible. Practice Problems -set 3, Page 6

Explanation / Answer

1.this.numYears = 0

2.numYears = this.numYears

3.this.numYears = this.numYears + numYears

4. None of the above

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote