Monday 3 July 2017

Program of interface in java

Program:

package JavaCoders;
/**
 *
 * @author Bsb
 */
interface abc
{
void m1();
}
interface bca
{
void m1();
}
class interface_example implements abc,bca
{
public void m1()
{
System.out.println("Balwant");
}
public static void main(String[] ar)
{
interface_example ob=new interface_example();
ob.m1();
}
}

In this program, interface can be made using word interface interface_name. You can declare as many methods as you can. But you have to implement it all. As we have to interface abc and bca in this program which contains the method m(). We are implementing these both interface and in this class we are defining this m1() method which contains the statement. Now we have to make object of this class. Using this class's object we are calling the method that will print "Balwant". The output of the program is given below:

Output:

Program-Of-Interface-in-java
Fig: Program of interface in java

No comments:

Post a Comment

Oracle / PLSQL: FOR LOOP

set serveroutput on; declare a1 varchar2(100); begin select count(*) into a1 from employees; for i in 1..a1 loop dbms_output.put_line...