I have shared enough theory on Multi-Threading in my previous post. Now, it is time to share code for Multi-Threaded programs by implementing runnable interface.
Showing posts with label Interface. Show all posts
Showing posts with label Interface. Show all posts
Nested Interface
Interfaces in Java, just like classes can be nested. An interface declared inside body of another interface is called nested interface. However, the two interfaces exists independently in terms of implemention. It means that one does not needs to implement the methods of both the interface if one implements only one of them. However, inner interface cant exist on its own,
Incomplete Interface Illustration
Java provides classes a choice to to implement an interface completely or just partially. But, opting to implement an interface renders a class incomplete. It means that the class that implements an interface incompletely, must be declared Abstract. Any class that extends such class, must implement remaining methods of the interface or should declare themselves as Abstract too.
Interface Illustrated
Via interfaces, one can specify what a class must do, but not how it should do it. An interface is just like a class and is defined in almost same way.
access interface_name
{
return_type method_name1(parameter_list);
return_type method_name2(parameter_list);
type final_var_name = value;
}
When no access specifier is given, access is understood to be default. Default access restricts the use of interface to the current package only.- Written Under Concepts, Demystified, Interface, Interfaces in Java
Subscribe to:
Posts (Atom)