top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the difference between Package and Inheritance in Java?

+2 votes
986 views
What is the difference between Package and Inheritance in Java?
posted Mar 16, 2015 by anonymous

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

Packages are a namespacing system that also corresponds to the organisation of classes in the filesystem hierarchy.

An interface is a type that requires certain methods be defined. It is referred to either in the heading of a class (as in class C implements interface X) and anywhere a type reference is required, excepting that an interface is not a "concrete" class and cannot be instantiated directly (with new).

package foo.bar.thing; // where in the package namespace the name Baz will be defined

import zik.zot.OtherThing; // references a class or interface in another package

public class Baz implements SomeInterface {
    private List<OtherThing> things; // requires elements implement this interface
}
answer Mar 16, 2015 by Karthick.c
...