Learn - Interfaces in Java
Interface
1.
Acts as a Blueprint or used as a Design.
2.
Naming convention same as Class – First letter of
each word should be Upper-Case.
3.
Its an Abstract Data type -
a.
CentralBank regulation à//Analogous
to String name
4.
Methods should be declared as abstract/unimplemented.
5.
Default access modifier for methods – public abstract.
6.
Default access modifier for variables defined – static
Final.
7.
Object creation is not possible for Interface.
a.
Reason- Memory to be provided is unpredictable
as we don’t define the behavior of methods in Interface.
8.
Object is created for the Implementation Class and
referenced by the Interface
a.
Eg –>
i.
CentralBank regulations = new HDFC();
ii.
CentralBank regulations = new Axis();
iii.
CentralBank regulations = new CentralBank(); --- X
//Regulations set by Central Bank commonly for all the Banks, which are
implemented by the respective Banks in their own way, adhering to the
regulations.
9.
Implements Keyword is used by the
Implementing classes, while implementing the Interface methods
a.
10.
Interface cannot implement another Interface.
11.
Interface
12.
Examples of Interfaces in Java
a.
List à
Implementing Class àArrayList
b.
Set à
Implementing Class àHashSet,
LinkedHasSet, HashMap
13.
Examples of Interfaces in Selenium
a.
WebDriver à
Implementing Class àRemoteWebDriver
à ChromeDriver, GeckoDriver,
InternetExplorerDriver
b.
WebElement
à Implementing Class àRemoteWebElement
Comments
Post a Comment