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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!