Java Chapter 3
Most class data fields are . a. private b. public c. static d. final
a. private
The method with the declaration public static int aMethod(double d) has a method type of . a. static b. int c. double d. You cannot determine the method type.
b. int
All method declarations contain. a. the keyword static b. one or more explicitly named access specifiers c. arguments d. parentheses
d. parentheses
The method public static boolean testValue(int response) returns a. a boolean value b. an int value c. no value d. You cannot determine what is returned.
a. a boolean value
If you use the automatically supplied default constructor when you create an object, a. numeric fields are set to 0(zero) b. character fields are set to blank c. Boolean fields are set to true d. All of these are true.
a. numeric fields are set to 0(zero)
In Java, methods must include all of the following except . a. a declaration b. a call to another method c. curly braces d. a body
b. a call to another method
Which of the following could be the last legally coded line of a method declared as public static int getVal(double sum)? a. return; b. return 77; c. return 2.3; d. Any of these could be the last coded line of the method.
b. return 77;
A method is declared as public static void showResults(double d, int i). Which of the following is a correct method call? a. showResults(double d, int i); b. showResults(12.2, 67); c. showResults(4, 99.7); d. Two of these are correct.
b. showResults(12.2, 67);
The method with the declaration public static char procedure(double d) has a method type of a. public b. static c. char d. double
c. char
A public static method named computeSum() is located in classA. To call the method from within classB, use the statement . a. computeSum(classB); b. classB(computeSum()); c. classA.computeSum(); d. You cannot call computeSum() from within classB.
c. classA.computeSum();
The concept of allowing a class's private data to be changed only by a class's own methods is known as a. structured logic b. object orientation c. information hiding d. data masking
c. information hiding
Which of the following method declarations is correct for a static method named displayFacts() if the method receives an int argument? a. public static int displayFacts() b. public void displayFacts(int data) c. public static void displayFacts(int data) d. Two of these are correct.
c. public static void displayFacts(int data)
If a class is named Student, the class constructor name is a. any legal Java identifier b. any legal Java identifier that begins with S c. Student Constructor d. Student
d. Student
Which of the following is a correct call to a method declared as public static void aMethod(char code)? a. void aMethod(); b. void aMethod('V'); c. aMethod(char 'M'); d. aMethod('Q');
d. aMethod('Q');