Hybrid inheritance in java
class Student {
int no;
void getno(int n) {
no=n; }
void show() {
[Link](no); }}
class Test extends Student {
int p1, p2;
void getm(int m1, int m2) {
p1=m1;
p2=m2; }
void showm()
[Link](p1);
[Link](p2);
interface sports
int s=7;
void putw();
class Result extends Test implements Sports
{
int total;
public void putw()
[Link](s);
void display()
total=p1+p2+s;
show();
showm();
putw();
[Link](total);
class Hybrid
public static void main(String args[])
Result s1=new Result();
[Link](11);
[Link](37, 45);
[Link]();
}
Multiple inheritance in java
interface Event { // interface 1
public void start();
interface Sports { // interface 2
public void play();
// another interface extending 1st and 2nd interface
interface Hockey extends Sports, Event{
public void show();
public class Tester{
public static void main(String[] args){
// creating instance of hockey
Hockey hockey = new Hockey() {
// implementing the methods of interfaces
public void start() {
[Link]("Start Event");
public void play() {
[Link]("Play Sports");
public void show() {
[Link]("Show Hockey");
};
// calling the methods using instance
[Link]();
[Link]();
[Link]();