Inheritance of Interface: An upbeat program
Interface P is extended by P1 and P2 interfaces. Interface P12 extends both P1 and P2.Each interface declares one method and one constant.
Download free Sample papers
Write a program that illustrate the inheritance of interface.
Interface P is extended by P1 and P2 interfaces. Interface P12 extends both P1 and P2.Each interface declares one method and one constant.
Create one class that implements P12. By using the object of the class invokes each of its method and displays constant.
interface P
{
final int p = 1;
void p_method();
}
interface P1 extends P
{
final int p1 = 2;
void p1_method();
}
interface P2 extends P
{
final int p2 = 3;
void p2_method();
}
interface P12 extends P1, P2
{
final int p12 = 4;
void p12_method();
}
class Class implements P12
{
public void p_method()
{
System.out.println("Hello from P");
System.out.println("P => " + p);
}
public void p1_method()
{
System.out.println("Hello from P1");
System.out.println("P1 => " + p1);
}
public void p2_method()
{
System.out.println("Hello from P2");
System.out.println("P2 => " + p2);
}
public void p12_method()
{
System.out.println("Hello from P12");
System.out.println("P12 => " + p12);
}
}
public class Practical17
{
public static void main(String[] args)
{
P12 pr = new Class();
pr.p_method();
pr.p1_method();
pr.p2_method();
pr.p12_method();
}
}
Watch java videos
Related Posts
Continue learning with these related articles

ISC Practical 2027: College Enrolment Code Validator and Stream Report – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 question: validate college enrolment codes made of a stream, year and serial number, give the exact reason for each rejection, auto-correct lowercase streams and prepare a stream-wise report.

ISC Practical 2027: Digital Lock Security Code Analyzer – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 number-logic question: for a 5 to 10 digit security code, find the first and last digits, odd and even position sums, product of non-zero digits, digit frequency and classify the code as STRONG, MODERATE or WEAK.

Boolean Algebra for ISC Class 12: Laws, Canonical SOP and POS, and Simplification
ISC Class 12 Computer Science notes on Boolean algebra: all the laws and theorems, duality, De Morgan's laws, minterms and maxterms, converting to canonical SOP and POS, and step-by-step algebraic simplification with solved examples.