Java exercise

User Generated

Nqrywhzznu

Programming

Description

please answer the attach file from exercise 1 to 25 that should be answered in java please do you best and do not bid to answer some of them you have to answer them all . thank you for your understanding

Unformatted Attachment Preview

User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Explanation & Answer

The answers to all the questions are in the word document attached. Please review the answers and notify me in case of any issues

1. Mark the following statements as true or false:
a. The instance variables of a class must be of the same type. FALSE
b. The methods of a class must be public. FALSE
c. A class can have more than one constructor. TRUE
d. A constructor can return a value of the int type. TRUE
e. An accessor method of a class accesses and modifies the data members of the class. FALSE
2. Answer the following questions:
a. Name of the class:
• State
b. The instance variables are:
• name,
• population, and
• area
c. Methods in the class are:
• State,
• setName,
• getName,
• setPopulation,
• getPopulation,
• setArea,
• getArea,
• toString,
• makeCopy,
• getCopy
d. Private members are the instance variables:
• name,
• population,
• area
e. Public members are the methods:
• State,
• setName,
• getName,
• setPopulation,
• getPopulation,
• setArea,
• getArea,
• toString,
• makeCopy,
• getCopy
3. Syntax errors:
• The second constructor is assigned a return type while constructors should not have a
return type
4. Syntax error:

5.

6.

7.
8.
9.
10.

11.

• The method declaration for the method ‘print’ has no return-type defined
Considering the class definition:
a. Constructor executed:...


Anonymous
Super useful! Studypool never disappoints.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4

Related Tags