The access_modifier specifies the whether the interface is public or not. If the access specifier is not specified for an interface then that interface will be accessible to all the classes present in that package only.
Interfaces
• The
interface can be defined using following syntax
access_modifier
interface name_of_interface
{
return_type
method_name1 (parameter1,parameter2,...parametern);
……..
return_type method_name1 (parameter1,parameter2,...parametern);
type static final
variable_name= value;
…….
}
• The
access_modifier specifies the whether the interface is public or not. If the
access specifier is not specified for an interface then that interface will be
accessible to all the classes present in that package only. But if the
interface is declared as public then it will be accessible to any of the class.
• The
methods declared within the interface have no body. It is expected that these
methods must be defined within the class definition.
An
interface is similar to a class but there lies some difference between the two.
Following
table presents the difference between the abstract class and interface.
Review
Question
1.
Present a detailed comparison between classes and interfaces.
Object Oriented Programming: Unit II: Inheritance, Packages and Interfaces : Tag: : Object Oriented Programming - Interfaces
Object Oriented Programming
CS3391 3rd Semester CSE Dept | 2021 Regulation | 3rd Semester CSE Dept 2021 Regulation