In Java, which of the following statements is/are TRUE?
S1: The ‘final’ keyword applied to a class definition prevents the class form being extended through derivation
S2: A class can only inherit one class but can implement multiple interfaces
S3: Java permits a class to replace the implementation of a method that it has inherited. It is called method overloading
only s1 and s2
correct statement for s3 is :
Java permits a class to replace the implementation of a method that it has inherited. It is called method over riding.
answer is S1 and S2 only.
the final keyword applied to class- prevent it from extending.
the final keyword applied to method- prevent it from overriding
the final keyword applied to variable- prevent it from changing the value.
class inherits(or extends only one class) and extends(or implements ) multiple interfaces.
replacement of method implementation is known as method overriding. its not method overloading. over loading is done by changing the no of argument which it is passed, or changing the datatype of arguments.