Home /
Expert Answers /
Computer Science /
use-the-below-code-as-shown-in-figure-1-to-answer-the-following-questions-1-what-is-the-output-o-pa928
(Solved):
Use the below code as shown in figure 1 to answer the following questions. 1. What is the output o ...
Use the below code as shown in figure 1 to answer the following questions. 1. What is the output of the classes in figure \( 1 . \) [4 marks] 2. Write another way to print out the value of counter variable in the main method. [2 marks] 3. Is it necessary to write setter and getter methods for attributes \( x \), and \( y \) ? Explain your answer. [2 marks] 4. Is it necessary to write getcounter() method to return the value of counter attribute? Explain your answer. [2 marks] 5. Is it valid to write the following statement inside the main method? Explain your answer. [2 marks] ColorRobot arr \( =\{ \) teto, deto \( \} ; \)
6. Extract from the classes in figure 1 the following: [8 marks \( ] \) 1. An accessor method. 2. A mutator method. 3. An instance method. 4. A class variable. 5. A parent class. 6. A child class. 7. A primitive type variable. 8. A reference type variable. 9. An overridden method. 10. A java keyword that is used to call a method from parent class. 11. An overloaded method. 12. A java keyword that is used to represent inheritance relationship. 13. An instance. 14. An instance variable. 15. An Access modifier. 16. A java keyword that is used to call constructor of super class.
1> Output of the program is attached below. 2> Another way to print counter variable is as shown below. System.out.println(Robot.counter); Since counter is a static variable it can be directly called using className.variablename. 3> Since Robot class