DATA STRUCTURES AND
ALGORITHMS TEST 1 QUESTIONS &
ANSWERS
ADT - Correct Answers -Abstract Data Type(ADT) is a data type, where only behavior is
defined but not implementation.
Java's List interface is an example
Generic Methods - Correct Answers -Java Generic methods and generic classes enable
programmers to specify, with a single method declaration, a set of related methods, or
with a single class declaration, a set of related types, respectively.
Rules to define Generic Methods - Correct Answers -All generic method declarations
have a type parameter section delimited by angle brackets (< and >) that precedes the
method's return type ( < E > in the next example).
Each type parameter section contains one or more type parameters separated by
commas. A type parameter, also known as a type variable, is an identifier that specifies
a generic type name.
The type parameters can be used to declare the return type and act as placeholders for
the types of the arguments passed to the generic method, which are known as actual
type arguments.
A generic method's body is declared like that of any other method. Note that type
parameters can represent only reference types, not primitive types (like int, double and
char).
Generic Classes - Correct Answers --A generic class declaration looks like a non-
generic class declaration, except that the class name is followed by a type parameter
section.
-The type parameter section of a generic class can have one or more type parameters
separated by commas. These classes are known as parameterized classes or
parameterized types because they accept one or more parameters.
-Ex:
ALGORITHMS TEST 1 QUESTIONS &
ANSWERS
ADT - Correct Answers -Abstract Data Type(ADT) is a data type, where only behavior is
defined but not implementation.
Java's List interface is an example
Generic Methods - Correct Answers -Java Generic methods and generic classes enable
programmers to specify, with a single method declaration, a set of related methods, or
with a single class declaration, a set of related types, respectively.
Rules to define Generic Methods - Correct Answers -All generic method declarations
have a type parameter section delimited by angle brackets (< and >) that precedes the
method's return type ( < E > in the next example).
Each type parameter section contains one or more type parameters separated by
commas. A type parameter, also known as a type variable, is an identifier that specifies
a generic type name.
The type parameters can be used to declare the return type and act as placeholders for
the types of the arguments passed to the generic method, which are known as actual
type arguments.
A generic method's body is declared like that of any other method. Note that type
parameters can represent only reference types, not primitive types (like int, double and
char).
Generic Classes - Correct Answers --A generic class declaration looks like a non-
generic class declaration, except that the class name is followed by a type parameter
section.
-The type parameter section of a generic class can have one or more type parameters
separated by commas. These classes are known as parameterized classes or
parameterized types because they accept one or more parameters.
-Ex: