SB Assuming that the following classes have been defined pub
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 (\ [SB] Assuming that the following classes have been defined: public class Dog extends Mammal public void methodl) System.out.println (\](/WebImages/8/sb-assuming-that-the-following-classes-have-been-defined-pub-995145-1761512126-0.webp)