Below is my code. I am not getting what is the mistake. Can anyone be able to guide.
class State {
static String country;
static String capital;
State() // Constructor
{
country = "America's";
capital = "Washington D.C";
}
static void display() {
System.out.println(capital + " " + "is" + " " + country + " " + "capital.");
}
}
class Place extends State // Method Overriding
{
static void display() {
System.out.println("Capital is Washington D.C.");
}
public static void main(String[] args) {
State st = new State();
Place pl = new Place();
st.display();
pl.display();
st = pl;
}
}
While running it displays as "Error: Could not find or load main class State$Place"
As the output needs: "Capital is Washington D.C." instead of (capital + " " + "is" + " " + country + " " +"capital.")