Java Reference
In-Depth Information
it is created. Keep all other members of the Stack class private. (Hint: You can use
the Queue class as a model; just change the way the data is accessed.)
4 . Given this class,
write a method called swap( ) that exchanges the contents of the objects referred to
by two Test object references.
5 . Is the following fragment correct?
6 . Write a recursive method that displays the contents of a string backwards.
7 . If all objects of a class need to share the same variable, how must you declare that
variable?
8 . Why might you need to use a static block?
9 . What is an inner class?
10 . To make a member accessible by only other members of its class, what access modifi-
er must be used?
11 . The name of a method plus its parameter list constitutes the method's
_______________.
12 . An int argument is passed to a method by using call-by-_______________.
13 . Create a varargs method called sum( ) that sums the int values passed to it. Have it
return the result. Demonstrate its use.
14 . Can a varargs method be overloaded?
15 . Show an example of an overloaded varargs method that is ambiguous.
Search WWH ::




Custom Search