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 ("CarpExplanation / 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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.