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

8)What will be displayed? a)write a method for Bunny class that OVERRIDES the ov

ID: 3836864 • Letter: 8

Question

8)What will be displayed? a)write a method for Bunny class that OVERRIDES the over method in Rabbit 8. [7 points] In the box show exactly what will be displayed by this Java program when executed. class Rabbit public Rabbit this ("Rabbit system out print ("Hare public Rabbits (String pika) System.out.print (pika) public over (string lapin) System.out.print ("over "+lapin) class Bunny extends Rabbit public Bunny System.out.print ("Bunny public Bunny (string who) super who System.out.print (who) public class ShowMe public static void main (String x) object 1 Bunny object new Bunny System. out .println In object2 Bunny object new Bunny ("Carp

Explanation / Answer

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author Surya
*/

class Rabbit
{
    public Rabbit()
    {
        //this("Rabbit");
        System.out.print("Hare ");
    }
    public Rabbit(String pika)
    {
        System.out.print(pika);
    }
    public void over(String lapin)
    {
        System.out.print("Over "+lapin);
    }
}
class Bunny extends Rabbit
{
    public Bunny()
    {
  
        System.out.print("Bunny ");
  
    }
  
    public Bunny(String who)
    {
        super(who);
  
        System.out.print(who);
    }
  
    //method to override the over method in Rabit class
    public void over(String lapin)
    {
        System.out.print(lapin);
  
    }
  
  
    //method to overload the over method in Rabit class
    public void over(String lapin,int n)
    {
  
        System.out.print(lapin+" "+n);
    }
  
  

}
public class ShowMe {
  

    public static void main(String[] x)
    {
        System.out.println("Objet1 :");
        Bunny object1 = new Bunny();
      
        System.out.println(" Object2 ");
        Bunny object2 = new Bunny("Carp");
      
  
    }


}

output:-

run:
Objet1 :
Hare Bunny
Object2
CarpCarp

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