Presentation Description

BCA 5th sem


Presentation Transcript



Slide 2:

Interface What is INTERFACE ? In the Java programming language, an interface is a reference type, similar to a class, that can contain only constants, method signatures, and nested types. There are no method bodies. Interfaces cannot be instantiated—they can only be implemented by classes or extended by other interfaces.

Slide 3:

Defining an Interface accessmodifier interface interfacename { returntype methodname(parameter-list); datatype var name=value; } Access is either public or not used . Methods are declared have no bodies and essentially abstract method. Each class that includes an interface must implement all of the methods. Variables are implicitly final and static, meaning they can't be change by the implementing class.

Slide 4:

Implementing Interface Class classname implements Interfacename { body of classname }

Access Protection:

Access Protection Private No Modifier Protected Public same class Y Y Y Y same package subclass N Y Y Y same package non-subclass N Y Y Y Different Package subclass N N Y Y Different Package non-subclass N N N Y

Slide 6:

Definition: A package is a grouping of related types (class, interface) providing access protection and name space management. Package PACKAGE JAVA API Packages: Contain built-in classes by the java. User Defined Packages: Packages are developed by programmer.

Slide 7:

Defining a package : package package-name; Importing a package : import packagename.classname; or import packagename.*; Using and creating Java package THANK YOU