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

Part 3(10points, 1pt/ea) Inheritance. write the output in the corresponding spac

ID: 3936569 • Letter: P

Question

Part 3(10points, 1pt/ea) Inheritance. write the output in the corresponding space class Test{ public static void main(stringl] args) Bird b new Bird() Dog d new Dog() String s University String s2 new String ("University") String s3 System.out.println("01) (s1 s2)); 1) System.out.println("(2) s equals(s2)) (2) (s2 s3)) (3) System.out.println( (3) System.out.println("(4) s2.equals(s3)); (4) System.out.println("(5) place ("e xx" (5) s3.rel system out.println ("(6)" d. Nlegs); (6) System out.println("(7) d.Neyes) (7) System.out.println("(8)" d.type) (8) system. out.println("(9) b.Nnose) (9) System. out.println("(1e)" b.type) (10) class Animal int Neyes 2; int Nlegs 3; int Nnose-1; string type "x";) class Mammal extends Animal int Nnose 2; int Nlegs 2; string type "M"; class Bird extends Mammal {String type "B": int Nlegs 1; class Dog extends Animal (int Niegs 4; int Neyes 3;) Part 4. (5 points) Exception Handling. Please write down the output in correct order. Please write the output: class Test public static void main(Stringll args) stem.out.println("Test try System out println("Test2"); int i 0; System out.println("Test3"); int y 2/i; System.out, println("Test4"); catch (RuntimeException ex) System out.println("Test5"); finally System.out,println("Test6 System out println("Test?

Explanation / Answer

part 3

(1) false
(2) true
(3) true
(4) true
(5) Univxxrsity
(6) 4
(7) 3
(8) X
(9) 2
(10) B

----------------------------------------------------------------------------------------------------------------------------------------------------------------

part 4:

First 1,2,3 tests will print, then divide by zero run time exception occurs, so it goes to catch block and prints 5th test and followed by finally block 6,7 tests.

so final answer is:

Test1
Test2
Test3
Test5
Test6
Test7

-----------------------------------------------------------------------------------------------------------------------------------------------------------

part 5:

1)

public static int fun(int n) {
if (n == 0) { //check for n==0
return 1;
} else if (n == 1) { //check for n==1
return 1;
}
return fun(n - 2) + fun(n - 1);
}

2)

fun(4) ==> fun(4-2) + fun(4-1)

===> fun(2) + fun(3)

==> fun(0) + fun(1) + fun(1) + fun(2)

===>  fun(0) + fun(1) + fun(1) +  fun(0) + fun(1)

====> 1 + 2 + 2 + 1 + 2 ===>. 8

----------------------------------------------------------------------------------------------------------------------------------------------------------

Part 6

1) NO, since it is calling parent constructor using super.
2) YES, printInfo in Faculty cannot override printInfo in person. Weaker privilage access. To fix this change it to public type.
3) NO, since only declaration a new object with no arguements.
4) YES, since person is abstract, cannot instantitate.
5) YES, since person is abstract, cannot instantitate.
6) YES, since empty constructor not declared.
7) YES, since rank has private access.
8) It will print f1 arguement "C"

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