49.0k views
0 votes
Create an abstract Division class with fields for a company's division name and account number, and an abstract display() method that will be defined in the subclasses. Use a constructor in the superclass that requires values for both fields. Create two subclasses named InternationalDivision and DomesticDivision. The InternationalDivision class includes a field for the country in which the division is located, a field for the language spoken, and a constructor that requires all fields when created. The DomesticDivision class include a field for the state in which the division is located and a constructor that requires all fields when created. Write an application named UseDivision that creates two instances of each of these concrete classes.

User Liam
by
3.7k points

1 Answer

3 votes

Answer:

// SAVE IN Division.java

public abstract class Division

{

protected String name;

protected String account_number;

public Division(String nam,String ac)

{

name = nam;

account_number = ac;

}

public abstract void display();

}

// END OF Division.java

// SAVE IN InternationalDivision.java

public class InternationalDivision extends Division

{

private String country;

private String language;

public InternationalDivision(String nam, String ac,String country,String lan)

{

super(nam,ac);

this.country = country;

this.language = lan;

}

public void display()

{

System.out.println( " name of company is " + name);

System.out.println( " Account number of company is " + account_number);

System.out.println( " company located in " + country);

System.out.println( " people in that company speak " + language);

}

}

// END OF InternationalDivision.java

// SAVE IN DomesticDivision.java

public class DomesticDivision extends Division

{

private String state;

public DomesticDivision(String nam, String ac,String sta)

{

super(nam,ac);

state = sta;

}

public void display()

{

System.out.println( " name of company is " + name);

System.out.println( " Account number of company is " + account_number);

System.out.println( " company located in the state " + state);

}

}

// END OF DomesticDivision.java

// SAVE IN UseDivision.java

public class UseDivision

{

public static void main(String[] args)

{

InternationalDivision ID1 = new InternationalDivision("Hero","11223344","China","Chinesse");

ID1.display();

System.out.println();

InternationalDivision ID2 = new InternationalDivision("Honda","1122334455","Singapore","Tamil");

ID2.display();

System.out.println();

DomesticDivision DD1 = new DomesticDivision("Ford","77223344","Arizona");

DD1.display();

System.out.println();

DomesticDivision DD2 = new DomesticDivision("Maruti","6188994455","Alaska");

DD2.display();

}

}

// END OF UseDivision.java

User Christian Heimes
by
3.1k points