Sunday 21 October 2018

What-is-the-difference-between-packages-and-interfaces-in-Java?tccicomputercoaching.com

packages and Interfaces both acts as a container. The content in packages and interfaces can be used by the classes by importing and implementing it correspondingly.

Let us see Difference between Package and Interface.

1. Definition:


Packages i
s a group of classes and/or interfaces together. The classes in packages are related to each other in some scope or by inheritance.
Interfaces is a group of abstract methods and constant fields. The methods declared in the interface are abstract that means the methods are only declared but not defined. The fields in the interface are always public, static, final. The fields must be initialized at the time of declaration.

2. How to Create?

Packages are created using "Package" keyword.
Interface are created using "Interface" keyword.

3. Syntax:

a.
package package_name;
public class class_name{
.
(body of class)
.
}
b.
interface interface_name{
variable declaration;
method declaration;
}

4. Access keyword:

a. A Packages can be imported using "import" keyword.
b. An interface can be extended by another interface and implemented by the class.
Interfaces can be implemented using "implement" keyword.

5. Basic Difference

Package is a Group of classes and interface.

When class implement interface.

TCCI Computer Coaching Class teach Java Language in Bopal and Satellite in Ahmedabad to the Computer-IT  Engineering , BCA, PGDCA, Diploma Engineering ,School Students and any Non-IT person.

To know more in detail about Package and interface in Java.

Call us @ 9825618292

Visit us @ http://tccicomputercoaching.com/

No comments:

Post a Comment