Class Running Notes 14th Oct
Class Running Notes 14th Oct
Concrete methods.
Interfaces:
i
thi
(a)static concrete methods(Java8)
ipa
(c)private concrete methods(Java9)
Ma
(a)static concrete methods(Java8):
Coding Rule:
nk
---------------------------------------------
Coding Rule:
object_reference.
i
thi
---------------------------------------------------
ipa
=>The concrete methods which are declared in interfaces using "private"
Coding Rule:
----------------------------------------------------------------
Diagram:
i
thi
ipa
Ex:
ITest.javaMa
package test;
public interface ITest {
public abstract void m1(int x);
public static void m2(int y) {
System.out.println("====static concrete m2(y)====");
sh
System.out.println("The value y:"+y);
}
default void m3(int z,int p,int q) {
ate
}
private static void show1(int p) {
System.out.println("====private static show1(p)====");
System.out.println("The value p:"+p);
Ve
}
private void show2(int q) {
System.out.println("====private Non-static show2(q)====");
System.out.println("The value q:"+q);
}
}
IClass.java
package test;
public class IClass implements ITest{
public void m1(int x) {
System.out.println("====method m1(x)====");
System.out.println("The value x:"+x);
}
}
DemoInterface4.java(MainClass)
package maccess;
i
thi
import test.*;
public class DemoInterface4 {
public static void main(String[] args) {
IClass ob = new IClass();
ipa
ob.m1(121);
ITest.m2(122);
//IClass.m2(123);//Error
ob.m3(124,125,126);
Ma
}
}
o/p:
sh
====method m1(x)====
=========================================================
Comparision Diagram:
i
thi
ipa
Ma
===========================================================
sh
ate
nk
Ve