Welcome

Anti Essays offers essay examples to help students with their essay writing.

Sign Up

Asst Essay

Open Document

Below is an essay on "Asst" from Anti Essays, your source for research papers, essays, and term paper examples.

What is the difference between a constructor and a method?
Constructors are a special type of method that is used to invoke a new object (p. 264). A constructor main purpose is to create an object. Constructors must have a similar class name and have the task of initializing the objects. Constructors are invoked when using the new operator when an object is created. A constructor differs from a method because it has no explicit return type and it is not implicitly inherited and it usually has different rules for scope modifiers.
Methods are “a collection of statements grouped together to perform an operation” (p. 178).   The purpose of methods is more general than constructors. A method's basic function is to execute the Java code. Methods are reusable codes that can be used for practically any task. A method has a header that specifies a modifier such as “public static”. Method also consists of return value type, method name, and parameters of the method.

What are appropriate cases for use of a constructor? Give an example.
It is appropriate to use a constructor when providing initial values for class fields when you create new objects. Example; recording students grades received for exams throughout the semester a constructor method could be used to record all the different grades.
What are appropriate uses of a method? Give an example
If your basic function is just to execute the Java code than it’s appropriate to use a method. Example; if you had to printout each students list of grades.

Liang, Y. (2013). Introduction to Java Programming. (9th ed.)   Boston, MA: PearsonConstructors are a special kind of methods that are invoked to construct objects.

Show More


Citations

MLA Citation

"Asst". Anti Essays. 15 Dec. 2018

<http://parimatch-stavka7.com/free-essays/Asst-529212.html>

APA Citation

Asst. Anti Essays. Retrieved December 15, 2018, from the World Wide Web: http://parimatch-stavka7.com/free-essays/Asst-529212.html


Pediatric-Kidney & Ureter-Reflux & Megaureter - 117 | Chap 137.5 2018-05-03 23:46:22 | 兄弟国语