How we can manipulate multiple inheritance using interfaces. please show me with examle code

  
Showing Answers 1 - 1 of 1 Answers

Guest

  • Mar 20th, 2006
 

multiple inheritance can be manipulated by using interfaces

INTERFACE:

interface is a method which can be created but can not be defined (coding)i.e,methods or interfaces can be defined and the implementation of methods or interfaces can be done in classes.

example:

imports system.console

sub main()

dim obj as new rain()  /* create an object for a class to call  a                   

obj.display()                                              method*/

obj.display1()

end sub

public Interface wind()

sub disaplay()

write("interface is created")

end Interface

public Interface ABC()

sub display1()

write("second interface")

end Interface

public class rain() implements wind(),ABC() /*"implements" keyword is used 

                                                                to implement the interface*/

                                                                    

                                                                 

public sub display implements wind.display()

write("interface wind is defined here")

end sub

end class

example 2:

imports system.console

sub main()

dim obj as new tot()

obj.setdata()

obj.display()

obj.r1()

obj.display()

obj.r2()

obj.display()

obj.r3()

obj.display()

obj.r4()

obj.display()

end sub

public Interface one()

sub r1()

sub r2()

end Interface

public Interface two()

sub r3()

sub r4()

end Interface

public class tot () implements one(),two()

dim i as integer

dim j as integer

dim sum as integer

sub setdata()

i=3

j=2

sum=0

end sub

public sub r1() implements one.r1 

sum=i+j

end sub

public sub r2() implements one.r2

sum=i-j

end sub

sub display()

write("sum")

end sub

public sub r4() implements two.r4

sum=i*j

end sub

public sub r3() implements two.r3

sum=i*j/2

end sub

end class

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions