What is wrong with the following Java code final class First
What is wrong with the following Java code?
final class First
 {
      private int a;
       int b;
       First()
       {
             a = 10;
            b = 20;
       }
 }
class Second extends First
 {
        public void method()
        {
              System.out.println( a + b);
       }
 }
SELECT ALLL POSSIBLE RESPONSES
Select one or more:
a. Because the variable a is private, no class other than First can access it.
b. Nothing is wrong with the code, it will compile.
c. The class Second cannot extend First, beacuse the class First is a terminal class.
d. final is not a valid keyword for a class, it is only used with constants.
e. You cannot call the println() method without passing a String to it.
Solution
Answer:
a. Because the variable a is private, no class other than First can access it.
c. The class Second cannot extend First, beacuse the class First is a terminal class.
These two are the correct answers.
Final class can not be inherited. So once we apply final key word on class that is a final class and can not be inherited.
\"a\" variable is a private variable and the scope of that variable is with in that same class and can not be visiblt to other classes.

