News:

Choose a design and let our professionals help you build a successful website   - ITAcumens

Main Menu

Interfaces (visual J#)

Started by sukishan, Sep 04, 2009, 03:55 PM

Previous topic - Next topic

sukishan

Interfaces
With constructs very similar to C#, the J# programming language also supports multiple inheritance using Interfaces (Listing 3.20). Actually, the simple mechanism of interface was in some sense introduced by Java and adopted by C#.

Listing 3.20 Using Interfaces (Visual J#)
package hks;
import System.*;
public class UseInterfaces
{
  public static void main()
  {
    Person hs = new Person();
    hs.set_Name("Hitesh Seth");
    hs.set_Address("1 Executive Driver, City, NJ 08520");
    Console.WriteLine(hs.GetName());
    Console.WriteLine(hs.GetAddress());
  }
}
public interface IName
{
   public String GetName();
}
public interface IAddress
{
  public String GetAddress();
}
public class Person implements IName, IAddress
{
  private String name, address;
  public Person()
  {
  }
  public void set_Name(String value)
  {
    name = value;
  }
  public void set_Address(String value)
  {
    address = value;
  }
  public String GetName()
  {
    return name;
  }
  public String GetAddress()
  {
    return address;
  }
}
A good beginning makes a good ending