Robot(Inheritance of interfaces): an easy program
Create an abstract class Robot that has the concretre subclasses ,RobotA, RobotB, RobotC. Class RobotA1 extends RobotA, RobotB1 extends RobotB and RobotC1 extends RobotC. There is interface Motion that declares 3 methods forward(), reverse() and stop(), implemented by RobotB and RobotC. Sound interf
JAVA videos
An interface in Java has a static constants and abstract methods. It is a mechanism to achieve abstraction. There can be only abstract methods in it, not method body. It is used to achieve abstraction and multiple inheritance in Java.
Create an abstract class Robot that has the concretre subclasses ,RobotA, RobotB, RobotC. Class RobotA1 extends RobotA, RobotB1 extends RobotB and RobotC1 extends RobotC. There is interface Motion that declares 3 methods forward(), reverse() and stop(), implemented by RobotB and RobotC. Sound interface declare method beep() implemented by RobotA1, RobotB1 and RobotC1. Create an instance method of each class and invoke beep() and stop() method by all objects.
abstract class Robot
{}
interface Motion
{
void forward();
void reverse();
void stop();
}
interface Sound
{
void Beep();
}
class RobotA extends Robot
{}
class RobotB extends Robot
{}
class RobotC extends Robot
{}
class RobotA1 extends RobotA implements Sound
{
public void stop()
{
System.out.println("Stop in RobotA1");
}
public void Beep()
{
System.out.println("Beep in RobotA1");
}
}
class RobotB1 extends RobotB implements Sound, Motion
{
public void forward()
{}
public void reverse()
{}
public void stop()
{
System.out.println("Stop in RobotB1");
}
public void Beep()
{
System.out.println("Beep in RobotB1");
}
}
class RobotC1 extends RobotC implements Sound, Motion
{
public void forward()
{}
public void reverse()
{}
public void stop()
{
System.out.println("Stop in RobotC1");
}
public void Beep()
{
System.out.println("Beep in RobotC1");
}
}
public class Practical18
{
public static void main(String[] args)
{
RobotA1 ra = new RobotA1();
RobotB1 rb = new RobotB1();
RobotC1 rc = new RobotC1();
ra.Beep();
ra.stop();
rb.Beep();
rb.stop();
rc.Beep();
rc.stop();
}
}
Interface programs
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.