Podcast
Questions and Answers
Why is the collection of the keys of a map a ______ and not a list?
Why is the collection of the keys of a map a ______ and not a list?
set
Why is the collection of the values of a map not a ______?
Why is the collection of the values of a map not a ______?
set
Suppose you want to track how many times each word occurs in a document. Declare a suitable ______ variable.
Suppose you want to track how many times each word occurs in a document. Declare a suitable ______ variable.
Map
What is a ______? Give a possible use for such a structure.
What is a ______? Give a possible use for such a structure.
Signup and view all the answers
A queue Allows you to add items to one end of the queue (the tail) Remove items from the other end of the queue (the head) Items are removed in the same order in which they were added First- in, first-out or FIFO order ❖ To visualize a queue, think of people ______ up.
A queue Allows you to add items to one end of the queue (the tail) Remove items from the other end of the queue (the head) Items are removed in the same order in which they were added First- in, first-out or FIFO order ❖ To visualize a queue, think of people ______ up.
Signup and view all the answers
The Queue interface in the standard Java library has: an add method to add an element to the tail of the queue, a remove method to remove the head of the queue, and a ______ method to get the head element of the queue without removing it.
The Queue interface in the standard Java library has: an add method to add an element to the tail of the queue, a remove method to remove the head of the queue, and a ______ method to get the head element of the queue without removing it.
Signup and view all the answers
The method walk() is ______, therefore it cannot be overridden.
The method walk() is ______, therefore it cannot be overridden.
Signup and view all the answers
For a binding of static, private and final methods, the type of the class is determined by the ______ at compile time.
For a binding of static, private and final methods, the type of the class is determined by the ______ at compile time.
Signup and view all the answers
In dynamic binding, if an object o invokes a method p, the JVM searches the implementation in classes C1, C2, ..., Cn-1, and ______.
In dynamic binding, if an object o invokes a method p, the JVM searches the implementation in classes C1, C2, ..., Cn-1, and ______.
Signup and view all the answers
In Java, the most general class is ______ class.
In Java, the most general class is ______ class.
Signup and view all the answers
Dynamic binding occurs at ______.
Dynamic binding occurs at ______.
Signup and view all the answers
Overriding occurs when methods are not static, private, or ______.
Overriding occurs when methods are not static, private, or ______.
Signup and view all the answers
To add new objects to our video game: Build a class that extends SpaceObject and provides its own draw method implementation. When objects of that class appear in the SpaceObject collection, the screen-manager code invokes method draw, exactly as it does for every other object in the collection, regardless of its type. So the new objects simply plug in without any modification of the screen manager code by the programmer. Tips to Remember… ❖ Polymorphism enables you to deal in generalities and let the execution-time environments handle the specifics.❖ You can tell objects to behave in manners appropriate to those objects, without knowing their specific types as long as they belong to the same inheritance hierarchy. Tips to Remember…(2) ❖ Polymorphism promotes extensibility: Software that invokes polymorphic behavior is independent of the object type to which the messages are sent. Therefore, new object types that can respond to the existing method calls can be added into a system without changing the base system. Only the client code that instantiates new objects must be changed to accommodate new types.
To add new objects to our video game: Build a class that extends SpaceObject and provides its own draw method implementation. When objects of that class appear in the SpaceObject collection, the screen-manager code invokes method draw, exactly as it does for every other object in the collection, regardless of its type. So the new objects simply plug in without any modification of the screen manager code by the programmer. Tips to Remember… ❖ Polymorphism enables you to deal in generalities and let the execution-time environments handle the specifics.❖ You can tell objects to behave in manners appropriate to those objects, without knowing their specific types as long as they belong to the same inheritance hierarchy. Tips to Remember…(2) ❖ Polymorphism promotes extensibility: Software that invokes polymorphic behavior is independent of the object type to which the messages are sent. Therefore, new object types that can respond to the existing method calls can be added into a system without changing the base system. Only the client code that instantiates new objects must be changed to accommodate new types.
Signup and view all the answers
Build a class that extends SpaceObject and provides its own ______ method implementation.
Build a class that extends SpaceObject and provides its own ______ method implementation.
Signup and view all the answers
When objects of that class appear in the SpaceObject collection, the screen-manager code invokes method ______, exactly as it does for every other object in the collection, regardless of its type.
When objects of that class appear in the SpaceObject collection, the screen-manager code invokes method ______, exactly as it does for every other object in the collection, regardless of its type.
Signup and view all the answers
Polymorphism enables you to deal in generalities and let the ______ handle the specifics.
Polymorphism enables you to deal in generalities and let the ______ handle the specifics.
Signup and view all the answers
You can tell objects to behave in manners appropriate to those objects, without knowing their specific types as long as they belong to the same ______ hierarchy.
You can tell objects to behave in manners appropriate to those objects, without knowing their specific types as long as they belong to the same ______ hierarchy.
Signup and view all the answers
Software that invokes polymorphic behavior is independent of the object type to which the messages are sent. Therefore, new object types that can respond to the existing method calls can be added into a system without changing the base system. Only the client code that instantiates new objects must be changed to accommodate new ______.
Software that invokes polymorphic behavior is independent of the object type to which the messages are sent. Therefore, new object types that can respond to the existing method calls can be added into a system without changing the base system. Only the client code that instantiates new objects must be changed to accommodate new ______.
Signup and view all the answers
Method sort sorts the elements of a List. The elements must implement the Comparable interface. The order is determined by the ______ order of the elements’ type as implemented by a compareTo method.
Method sort sorts the elements of a List. The elements must implement the Comparable interface. The order is determined by the ______ order of the elements’ type as implemented by a compareTo method.
Signup and view all the answers
Method compareTo is declared in interface Comparable and is sometimes called the ______ comparison method.
Method compareTo is declared in interface Comparable and is sometimes called the ______ comparison method.
Signup and view all the answers
The sort call may specify as a second argument a Comparator object that determines an alternative ______ of the elements.
The sort call may specify as a second argument a Comparator object that determines an alternative ______ of the elements.
Signup and view all the answers
The Comparator interface is used for sorting a Collection’s elements in a different ______.
The Comparator interface is used for sorting a Collection’s elements in a different ______.
Signup and view all the answers
The static Collections method reverseOrder returns a Comparator object that orders the collection’s elements in ______ order.
The static Collections method reverseOrder returns a Comparator object that orders the collection’s elements in ______ order.
Signup and view all the answers
Static Collections method binarySearch locates an object in a List. If the object is found, its index is returned. If the object is not found, binarySearch returns a ______ value.
Static Collections method binarySearch locates an object in a List. If the object is found, its index is returned. If the object is not found, binarySearch returns a ______ value.
Signup and view all the answers
Generic programming is the creation of programming constructs that can be used with many different types. In Java, this is achieved with type parameters or with ______.
Generic programming is the creation of programming constructs that can be used with many different types. In Java, this is achieved with type parameters or with ______.
Signup and view all the answers
Java Generics enables the programmer to create a single class, interface, and method which can be used with different types of objects, thus enabling code ______.
Java Generics enables the programmer to create a single class, interface, and method which can be used with different types of objects, thus enabling code ______.
Signup and view all the answers
Primitive data types such as int, char, and float do not work with generics. For example, ______ is not allowed.
Primitive data types such as int, char, and float do not work with generics. For example, ______ is not allowed.
Signup and view all the answers
A generic class has one or more type parameters. A type parameter for ArrayList denotes the element type, for example: public void add(E element) public E get(int index). Here, 'E' represents the ______ type.
A generic class has one or more type parameters. A type parameter for ArrayList denotes the element type, for example: public void add(E element) public E get(int index). Here, 'E' represents the ______ type.
Signup and view all the answers
Type parameters in Java generics can be instantiated with class or interface types. For example, ArrayList uses String as the type parameter. However, you cannot use a primitive type like int directly as a type parameter, for instance: ArrayList is ______.
Type parameters in Java generics can be instantiated with class or interface types. For example, ArrayList uses String as the type parameter. However, you cannot use a primitive type like int directly as a type parameter, for instance: ArrayList is ______.
Signup and view all the answers
In generic programming, the objective is to create programming constructs that can work with various types. This flexibility is achieved through the use of type parameters or ______.
In generic programming, the objective is to create programming constructs that can work with various types. This flexibility is achieved through the use of type parameters or ______.
Signup and view all the answers