Professional Documents
Culture Documents
I pledge by honor that I will not discuss this exam with anyone until my
instructor reviews the exam in the class.
(50 minutes)
Part I.
// Fill in the code to invoke the sum method and display the sum of i and j.
}
}
// Fill in the code to invoke the printSum method to display the sum of i and j.
1
}
a. (3 pts)
System.out.println();
}
}
b. (3 pts)
System.out.println();
}
}
2
Part III:
i m(i)
1 0.3333
2 0.7333
.
.
.
19 8.7602
20 9.2480
}
}
3
b. (5 pts) Write a method that will display numbers from 1 to n, 7
numbers per line. The numbers are separated by one space. The
method header is as follows:
4
Part IV: Multiple Choice Questions: (1 pts each)
(1. Mark your answers on the sheet. 2. Login and click Take
Instructor Assigned Quiz for Quiz3. 3. Submit it online
within 5 mins. 4. Close the browser.)
1 What is Math.rint(3.5)?
A. 3
B. 5.0
C. 4
D. 3.0
E. 4.0
#
2 Suppose
#
3 (char)('a' + Math.random() * ('z' - 'a' + 1)) returns a random character
__________.
A. between 'a' and 'y'
B. between 'b' and 'z'
C. between 'b' and 'y'
D. between 'a' and 'z'
#
4 The signature of a method consists of ____________.
A. method name and parameter list
B. return type, method name, and parameter list
C. parameter list
D. method name
#
5. Analyze the following code:
class Test {
public static void main(String[] args) {
System.out.println(xMethod((double)5));
}
5
return n;
}
#
6 A variable defined inside a method is referred to as __________.
A. a local variable
B. a block variable
C. a global variable
D. a method variable
#
7 When you invoke a method with a parameter, the value of the argument is
passed to the parameter. This is referred to as _________.
A. pass by name
B. pass by value
C. pass by reference
D. method invocation
#
8 Which of the following should be declared as a void method?
A. Write a method that returns a random integer from 1 to 100.
B. Write a method that prints integers from 1 to 100.
C. Write a method that checks whether current second is an integer from 1 to
60.
D. Write a method that converts an uppercase letter to lowercase.
#
9 Each time a method is invoked, the system stores parameters and local
variables in an area of memory, known as _______, which stores elements in
last-in first-out fashion.
A. storage area
B. a heap
C. a stack
D. an array
6
What is your score? ______________
7
Another random document with
no related content on Scribd:
—Sssjesjjtig, siste ze even uit, met ’n wenk van ’r
magere knokels, sluw, schuchter toch.—
—Veertig éenmoal.…
—Wa’ mot dur medam mi’ knaine van doen? sai frait
d’r puur kalkoene!.…
—Vaif en sestig!.…
—Mooi soo!.… gooit de boel òp waife;.… aa’s alles
brandt brandt woater ook.. la’ jullie je aige nie troefe..
van die gele sloerie-ekster,—stootte ’n venter uit,
grinnekend tegen ’n buurman. [147]
—Koffie main!
—Nou wà’ sel ’t?.… betoàl ’k hullie nie? houw tot soo
[156]langest je snoater,.… nou hoor-je Dirk? daa’s tug
puur naitig bakke, allain van main rechterhoek!.…
—’t Is d’r dan ook duufels mit hoàst gonge hee?.. zei
met diepe stem, zangerig, ’n venter vlak bij Dirk.
Achter middenschot van bank zat ie, met verdraaid lijf,
alleen neusbrok en oogen er boven uitloenschend
naar de kerels.
—Nou daa’s nie net, onthutst zei Grint, moar nou mo’
je.. mó’ je ook segge dâ je van ’t winter.… al kèrtak
moakt hep.. van hoeveul je laif’re mot.—’n Màn, ’n
man,… ’n woord, ’n woord.… hee?.… wa’ jou Dirk?.…
wá’ jou Staine, wa jou.… Gais?.… je hoef d’r ommers
nie veur de heule mikmak te f’rkertakteere?.…