Java Unit 4
Java Unit 4
using the `extends` keyword in Java. When a class extends another class, it
inherits all the members (fields and methods) of the parent class, and can also add its
own members.
Overriding Methods:
In Java, a subclass can provide its own implementation for a method that is already
defined in its superclass. This is known as method overriding. To override a method, the
subclass must define a method with the same name, return type, and parameter list as
the superclass's method.
Access Control: Access control in Java is used to restrict access to the classes,
methods, and variables of a package or class. There are four access modifiers in Java -
public, private, protected, and default. These access modifiers are used to control the
visibility of classes, methods, and variables.