Java Packages Interfaces
Java Packages Interfaces
1. Packages:
Example:
package MyPackage;
2. Access Protection:
Example:
class Demo {
}
3. Importing Packages:
Example:
import MyPackage.MyClass;
obj.display();
4. Interfaces:
Example:
interface Animal {
void makeSound();
5. Defining Interfaces:
Example:
interface Vehicle {
void start();
}
6. Implementing Interfaces:
Example:
System.out.println("Car is starting...");
7. Applying Interfaces:
Example:
v.start();
8. Extending Interfaces:
Example:
interface Engine {
void run();
System.out.println("Running...");