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

Logic Gates for ISC Class 11: Truth Tables, Universal Gates, Half and Full Adder
ISC Class 11 Computer Science notes on logic gates: AND, OR, NOT, NAND, NOR, XOR and XNOR with truth tables, why NAND and NOR are universal gates, and half adder and full adder circuits with their Boolean expressions.
Decimal to Binary Conversion in Java: 3 Programs with Examples
How to convert a decimal number to binary on paper and in Java: three programs (String, place value and Integer.toBinaryString), binary to decimal, a dry run and common mistakes.

ISC Class 11 Computer Science Sample Paper 2026-27 with Solutions
A full 70-mark ISC Class 11 Computer Science sample paper for the 2026-27 annual exam: MCQs, number systems, propositional logic, logic gates, Java classes, arrays, strings, searching and sorting, and computing ethics, with complete worked solutions.