public class Cat { private int age; private int weight; public Cat(int a) { age = a; } public int getAge() { return weight; } } Which of the following best explains why the getAge method will NOT work...


7


public class Cat<br>{<br>private int age;<br>private int weight;<br>public Cat(int a)<br>{<br>age =<br>a;<br>}<br>public int getAge()<br>{<br>return weight;<br>}<br>}<br>Which of the following best explains why the getAge method will NOT work as<br>intended?<br>The instance variable age should be returned instead of weight, which is local to the<br>constructor.<br>The variable age is not declared inside the getAge method.<br>The getAge method should be declared as private.<br>The getAge method should have at least one parameter.<br>

Extracted text: public class Cat { private int age; private int weight; public Cat(int a) { age = a; } public int getAge() { return weight; } } Which of the following best explains why the getAge method will NOT work as intended? The instance variable age should be returned instead of weight, which is local to the constructor. The variable age is not declared inside the getAge method. The getAge method should be declared as private. The getAge method should have at least one parameter.

Jun 04, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions ยป

Submit New Assignment

Copy and Paste Your Assignment Here