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

Learning to Program with Robots(JAVA) The link of the textbook: http://www.learn

ID: 3866839 • Letter: L

Question

Learning to Program with Robots(JAVA)

The link of the textbook: http://www.learningwithrobots.com/textbook/PDFs/WholeThing.pdf

12.1 The move method in the LeftDancer class (see Listing 12-1) contains the statement super.move() (lines 16, 18, and 20). What would happen if one of those statements were this.move()?

FIND THE Listing 12-1: A robot that dances to the left as it moves forward ch12dancers/ 1 import becker.robots.* 2 3. LeftDancers dance to the left as they move forward. 5 * @author Byron Weber Becker 6 public class LeftDancer extends RobotSE 8 public LeftDancer (City c, int str, int ave, Direction dir) 9 super (c, str, ave, dir); 10 this.setLabel("L") 12 13 Dance to the left. "I 14 public void move () 15 this.turnLeft); 16 17 18 19 super.move () this.turnRight( super.move ); this.turnRight ) super.move ); this.turnLeft); 20 21 23 h

Explanation / Answer

Answer: When we use "super" keyword on method then it will call super class method.

When super.move() statement executes, it will class Super class RobootSE method move().

If we call this.move() instead of super.move() then it will execute current class method move(). Since we are executing move() method and calling same method by this keyword inside the method, it will lead to StackOverFlowError.

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