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

Page 1

What-is-the-difference-between-packages-andinterfaces-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 is a group of classes and/or interfaces together. The classes in packages are related to each other in some scope or by inheritance. Interfaces are 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 public . (body . }

class of

package_name; class_name{ class)

b. interface variable method }

interface_name{ declaration; declaration;


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.
What-is-the-difference-between-packages-and-interfaces-in-Java? tccicomputercoaching.com by Rosario Riley - Issuu