Part 310points 1ptea Inheritance write the output in the cor
Solution
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\"
![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 ne 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 ne](/WebImages/25/part-310points-1ptea-inheritance-write-the-output-in-the-cor-1064783-1761556806-0.webp)
![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 ne 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 ne](/WebImages/25/part-310points-1ptea-inheritance-write-the-output-in-the-cor-1064783-1761556806-1.webp)