Question: Explain the difference between a static and a non-static method. Consider the following class and assume each of the methods returns a valid value or
Explain the difference between a static and a non-static method.
Consider the following class and assume each of the methods returns a valid value or object according to the return type:
class House
{
public static int getHouses() { }
public static House createHouse() { } public House() { } public String getColor() { }
public void main(String[] args) {
//A
House h1 = new House();
//B
House h2 = House.createHouse();
//C
System.out.println(House.getColor());
//D
System.out.println(h1.getColor());
//E
System.out.println(h1.getHouses());
}
}
Which of the statements A-E are valid? For those, that are not explain why or why not. <-----
please help. thanks for the help
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
