Question 14
Consider the Java code given below.
interface Element { void display();}class PeriodicTableElement { private String group; public void setGroup(String g) { this.group = g; } public String getGroup() { return group; } public Element createElement() { switch (getGroup()) { case "Metal": return new Metal(); case "Nonmetal": return new Nonmetal(); case "Metalloid": return new Metalloid(); default: return null; } } private class Metal implements Element { public void display() { System.out.println("Metal properties"); } } private class Nonmetal implements Element { public void display() { System.out.println("Nonmetal properties"); } } private class Metalloid implements Element { public void display() { System.out.println("Metalloid behavior"); } }}public class ChemistryLab { public static void main(String[] args) { PeriodicTableElement pt = new PeriodicTableElement(); pt.setGroup("Metalloid"); // --------- Line X --------- }}Identify the appropriate option to fill in place of LINE X such that the output is:
Metalloid behavior