Interface in Java

This Simple Java Program is for performing Interfaces in Java. This is a part of Mumbai University MCA Colleges Java Practicals.


Interface just carry the signature of the function to be used. The class which implements a interface has to define the function which its gonna implement.

.

interface Exam
{
boolean pass(int marks);
}

interface Classify
{
String division(int avg);
}

class Result implements Exam,Classify
{
public boolean pass(int marks)
{
System.out.println("Marks obtained are "+ marks);
if(marks>=50)
return true;
else
return false;
}
public String division(int avg)
{
if(avg>=60)
return("First Division");
else if(avg>50)
return("Second Division");
else
return("Third Division");
}
public static void main(String ar[])
{
Result r =new Result();
boolean flg;
flg=r.pass(60);
if(flg==true)
System.out.println("Marks>=50");
else
System.out.println("Marks<50");
System.out.println(r.division(60)); 
}
}

Hope this Java Program is useful to you in some sense or other. Keep following this blog for more Mumbai University MCA College Programs and simple Programs. Happy Programming and Studying

No comments:

Post a comment