Disccussion 3 - This is a group discussion assignment for a object and class in a java program PDF

Title Disccussion 3 - This is a group discussion assignment for a object and class in a java program
Author Mathew Adulola
Course Programming 1
Institution University of the People
Pages 2
File Size 96 KB
File Type PDF
Total Downloads 96
Total Views 142

Summary

This is a group discussion assignment for a object and class in a java program...


Description

Discuss the concept of parameters. What are parameters for? What is the difference between formal parameters and actual parameters? Give an example in Java code that illustrates formal parameters and actual parameters. Your Discussion should be at least 250 words in length, but not more than 750 words. Once you’ve completed your initial post, be sure to respond to the posts of at least 3 of your classmates. Answer The of concept of parameters: according to (Javanotes 8.1, Section 4.3 -- Parameters, 2021). parameter is something that provides a mechanism for passing information from the outside world into the box. Parameters are part of the interface of a subroutine. They allow you to customize the behavior of a subroutine to adapt it to a particular situation. Parameters can also be defined as the variables that are listed as part of a method declaration. Each parameter must have a unique name and a defined data type. . What are parameters for: A parameter is a special kind of variable used in a function to refer to one of the pieces of data provided as input to the function. These pieces of data are the values of the arguments with which the function is going to be called/ invoked. An ordered list of parameters is usually included in the definition of a function, so that, each time the function is called, its arguments for that call are evaluated, and the resulting values can be assigned to the corresponding parameters.

What is the difference between formal parameters and actual parameters formal parameter — the identifier used in a method to stand for the value that is passed into the method by a caller, while actual parameter — the actual value that is passed into the method by a caller.

Give an example in Java code that illustrates formal parameters and actual parameters. Import javax.swingJOptionPane; Public class unit3 { Static void printhello(String x) // X is formal parameter { //message dialog for Hello sentence

JOptionPane.show.MessageDialog(null, “Hello ” +x); } public static void main(String[] args) { String y = “World”; Printhello(y); // Y is actual parameter }

} The output

X is the formal parameter Y is the actual parameter

References Javanotes 8.1, Section 4.3 -- Parameters. (2021). Hws.edu. http://math.hws.edu/javanotes/c4/s3.html...


Similar Free PDFs