SB Assuming that the following classes have been defined pub

[SB] Assuming that the following classes have been defined: public class Dog extends Mammal public void methodl) System.out.println (\"Dog 1\") super.method2 ) public void method2 System.out.println (\"Dog 2\") public class Animal i public void method2) System.out.println (\"Animal\") public class Bulldog extends Dog public void method2 System.out.printin (\"Bulldog 2\") public class Mammal extends Animal public void method3 ) i

Solution

Hi,

Please find answer for first 12 questions.

Post rest of questions in separate post.


   Mammal var1 = new Bulldog()
   Animal var2 = new Animal()
   Animal var3 = new Mammal()
   Object var4 = new Dog()
   Mammal var5 = new Dog()
   Dog var6 = new Bulldog()

   1) var1.method2() : Bulldof 2
   2) var2.method2() : Animal
   3) var3.method2() : Animal (inherited from Animal)
   4) var4.method2() : Error as we do not have method2 in Object class
   5) var5.method2() : Dog 2
   6) var6.method2() : Bulldog 2

   7) var1.method3() :
                       Mammal 3 // inherited from Mammal
                       Bulldof 3 //Bulldog method2 output

   8) var2.method3() : Error, we do not have method3 in Animal
   9) var3.method3() : Error, we do not have method3 in Animal
   10) var4.method3() : Error as we do not have method3 in Object class
   11) var5.method3() :
                       Mammal 3 // inherited from Mammal
                       Dog 3 //Dog method2 output
   12) var6.method3() :
                       Mammal 3 // inherited from Mammal
                       Bulldof 3 //Bulldog method2 output

 [SB] Assuming that the following classes have been defined: public class Dog extends Mammal public void methodl) System.out.println (\

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site