Question 20
Show the proper syntax for declaring a variable of type double and initializing its value to 5.5.
Question 21
Show the proper syntax for declaring a variable of type Double and initializing its value to 5.5.
Question 22
Show the proper syntax for extracting the value from a variable of type Double .
Question 23
True or false? In Java, the name of a reference variable evaluates to the address of the location in memory where the variable is stored.
Question 24
What is a legal identifier in Java?
Question 25
What are the rules for variable names in Java?
Question 26
What is meant by the scope of a Java variable?
Question 27
What are the four possible scope categories for a Java variable?
Question 28
What is a member variable?
Question 29
Where are local variables declared in Java?
Question 30
What is the scope of a local variable in Java?
Question 31
What defines a block of code in Java?
Question 32
What is the scope of a variable that is declared within a block of code that is defined within a method and which is a subset of the statements that make upthe method?
Question 33
What is the scope of a variable declared within the initialization clause of a for statement in Java? Provide an example code fragment.
Question 34
What are method parameters and what are they used for?
Question 35
What is the scope of a method parameter ?
Question 36
What are exception handler parameters ?
Question 37
Write a Java application that illustrates member variables (class and instance) , local variables, and method parameters.
Question 38
True or false? Member variables in a Java class can be initialized when the class is defined.
Question 39
How are method parameters initialized in Java?
Listings
What is the meaning of the following two images?
This image was inserted here simply to insert some space between the questions and the answers to keep them from being visible on the screen at thesame time.
The image is also an example of the kinds of things that we do in my course titled ITSE 2321, Object-Oriented Programming.
This image was also inserted for the purpose of inserting space between the questions and the answers.
Answers
Answer 39
Method parameters are initialized by the values passed to the method.
Answer 38
True.
Answer 37
See the application named member1 in this module for an example of such an application.
Answer 36
Exception handler parameters are arguments to exception handlers, which will be discussed in a future module.
Answer 35
The scope of a method parameter is the entire method for which it is a parameter.
Answer 34
Method parameters are the formal arguments of a method. Method parameters are used to pass values into and out of methods.
Answer 33
Java treats the scope of a variable declared within the initialization clause of a for statement to be limited to the total extent of the for statement. A sample code fragment follows where cnt is the variable being discussed: