Exam 7: User-Defined Methods

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

public class scopeRule //Line 1 { //Line 2 Static double intRate = 0.055; //Line 3 Static String name; //Line 4 Static int t; //Line 5 public static int main(String[] args) //Line 6 { //Line 7 Int first; //Line 8 Double u, t; //Line 9 String str; //Line 10 //... //Line 11 } //Line 12 public static int first(int x, int y) //Line 13 { //Line 14 Int t; //Line 15 //... //Line 16 } public static double salary; //Line 17 public static void funcOne(int first, double x) //Line 18 { //Line 19 Char ch; //Line 20 Int y; //Line 21 //block one //Line 22 { //Line 23 Int u = 18; //Line 24 //... //Line 25 } //end block one //Line 26 } //Line 27 } //Line 28Which of the following identifiers seen in the accompanying figure is visible in method first?

Free
(Multiple Choice)
4.9/5
(32)
Correct Answer:
Verified

A

public class scopeRule //Line 1 { //Line 2 Static double intRate = 0.055; //Line 3 Static String name; //Line 4 Static int t; //Line 5 public static int main(String[] args) //Line 6 { //Line 7 Int first; //Line 8 Double u, t; //Line 9 String str; //Line 10 //... //Line 11 } //Line 12 public static int first(int x, int y) //Line 13 { //Line 14 Int t; //Line 15 //... //Line 16 } public static double salary; //Line 17 public static void funcOne(int first, double x) //Line 18 { //Line 19 Char ch; //Line 20 Int y; //Line 21 //block one //Line 22 { //Line 23 Int u = 18; //Line 24 //... //Line 25 } //end block one //Line 26 } //Line 27 } //Line 28Which of the following identifiers seen in the accompanying figure is NOT visible in method funcOne?

Free
(Multiple Choice)
4.8/5
(40)
Correct Answer:
Verified

B

If a formal parameter is a variable of a primitive data type, then after copying the value of the actual parameter, there is no connection between the formal and actual parameter.

Free
(True/False)
4.7/5
(31)
Correct Answer:
Verified

True

When a program executes, the first statement to execute is always the first statement in the main method.

(True/False)
4.8/5
(48)

An identifier can be declared anywhere including within a class, and outside of every method definition (and every block).

(True/False)
4.8/5
(34)

What is an actual parameter?

(Multiple Choice)
4.7/5
(33)

Java allows the programmer to declare a variable in the initialization statement of the for statement.

(True/False)
4.8/5
(38)

How can a method send a primitive value back to the caller?

(Multiple Choice)
4.8/5
(40)

Strings assigned to StringBuffer variables can be altered.

(True/False)
4.8/5
(33)

Which of the following is NOT true about return statements?

(Multiple Choice)
4.9/5
(40)

Void methods use the return statement to return the value 0.

(True/False)
4.7/5
(37)

Void methods must have at least one parameter.

(True/False)
4.7/5
(36)

Within a method, an identifier used to name a variable in the outer block of the method can be used to name any other variable in an inner block of the method.

(True/False)
4.8/5
(43)

public static double secret(int first, double second) { Double temp; if (second > first) Temp = first * second; Else Temp = first - second; return temp; }Which of the following is NOT part of the heading of the method in the accompanying figure?

(Multiple Choice)
4.8/5
(33)

To use a predefined method, you must know the code in the body of the method.

(True/False)
4.9/5
(34)

The signature of a method consists of only its formal parameter list.

(True/False)
4.7/5
(37)

public static double secret(int first, double second) { Double temp; if (second > first) Temp = first * second; Else Temp = first - second; return temp; }What is the return type of the method in the accompanying figure?

(Multiple Choice)
4.9/5
(33)

public static char methodHeading(int n, double num)Which of the following statements about the method heading in the accompanying figure is NOT true?

(Multiple Choice)
4.9/5
(37)

In order to use the method isUpperCase of the class Character, the package java.lang must be explicitly imported.

(True/False)
4.8/5
(38)

public int mystery(int x, int y) { If (x >= y) Return x - y; Else Return x + y; }Based on the code in the accompanying figure, what would be the output of the following statement?System.out.println(mystery(8,7));

(Multiple Choice)
4.9/5
(30)
Showing 1 - 20 of 50
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)