Programming Languages Chapter 20 Overloaded methods are often used to perform 

subject Type Homework Help
subject Pages 3
subject Words 820
subject Authors Harvey Deitel, Paul Deitel

Unlock document.

This document is partially blurred.
Unlock all pages and 1 million more documents.
Get Access
page-pf1
Chapter 20 Generic Classes and Methods
20.1 Q1: __________ enable programmers to specify, with a single method declaration, a set of related
methods.
a. Overloaded methods.
b. Overriden methods.
c. Generic methods.
d. Generics.
20.1 Q2: Generics provide __________ that allows programmers to catch invalid types at compile time.
a. compile-time type safety.
b. compile-time exception handling.
c. compile-time error checking.
d. run-time type safety.
20.2 Q1: Which of the following statements is true?
a. Overloaded methods are often used to perform similar operations on different types of data.
b. When the compiler encounters a method call, it attempts to locate a method declaration with a name and
parameters that are compatible with the argument types in the method call.
c. Both a) and b) are true.
d. Neither a) nor b) is true.
20.3 Q1: All generic method declarations have a type parameter section delimited by __________.
a. curly brackets ({ and }).
b. angle brackets (< and >).
c. square brackets ([ and ] ).
d. parenthesis.
20.3 Q2: Which statement is false?
a. When declaring a generic method, the type parameter section is placed before the return type of the
method.
b. Each type parameter section contains only one type parameter.
c. A type parameter is an identifier that specifies a generic type name.
d. Type parameters can represent only reference types.
20.4 Q1: __________ is the default upper bound of a type parameter.
a. String.
page-pf2
b. Comparable.
c. Class.
d. Object.
20.4 Q2: When the compiler translates a generic method into Java bytecodes, it uses __________ to replace
the type parameters with actual types.
a. erasure.
b. compile-time type replacement.
c. compile-time type checking.
d. compile-time type safety.
20.5 Q1: Which statement is false?
a. A generic method may be overloaded.
b. A class can provide two or more generic methods that specify the same method name but different
method parameters.
c. A generic method cannot be overloaded by non-generic methods.
d. When the compiler encounters a method call, it searches for the method declaration that most precisely
matches the method name and the argument types specified in the call.
20.6 Q1: One generic Stack class could be the basis for creating many Stack classes, e.g., Stack<Double>,
Stack<Integer> and Stack<Employee>. These classes are known as __________.
a. subclasses.
b. generic subclasses.
c. concrete classes.
d. parameterized classes.
20.6 Q2: When compiling a generic class, the __________ option should be used to view the unchecked
warning message.
a. -Xlint:unchecked.
b. -X:unchecked.
c. -warning:unchecked.
d. -unchecked.
20.7 Q1: When a generic class is instantiated without specifying a type argument, it is said to have a
__________.
a. empty type.
b. raw type.
c. null type.
d. abstract type.
20.7 Q2: Suppose Stack is a generic class that has one type parameter. The assignment
page-pf3
Stack<Integer> integerStack = new Stack(10);
a. is illegal.
b. is permitted and safe.
c. is permitted but unsafe, the compiler issues a warning message.
d. is permitted but unsafe, the runtime environment issues a warning message.
20.8 Q1: Class Number is ________ of both Integer and Double.
a. the subclass
b. composed
c. a descendent
d. the superclass
20.8 Q2:Which of the following statements is false?
a. Wildcard type arguments enable you to specify method parameters, return values, variables, and so on,
that act as supertypes of parameterized types.
b. A wildcard-type argument is denoted by ?, which represents an “unknown type.”
c. Because a wildcard is a type-parameter name, you can use it as a type name throughout a method’s body.
d. If a wildcard is specified without an upper bound, then only the methods of type Object can be invoked
on values of the wildcard type.
20.8 Q3: A wildcard type argument is denoted by a(n) __________.
a. asterisk (*).
b. underscore (_).
c. question mark (?).
d. caret (^).

Trusted by Thousands of
Students

Here are what students say about us.

Copyright ©2022 All rights reserved. | CoursePaper is not sponsored or endorsed by any college or university.