Extending Classes in Video Game Development

DeftCharoite avatar
DeftCharoite
·
·
Download

Start Quiz

Study Flashcards

30 Questions

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 ______?

set

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.

Map

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.

lining

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.

peek

The method walk() is ______, therefore it cannot be overridden.

static

For a binding of static, private and final methods, the type of the class is determined by the ______ at compile time.

compiler

In dynamic binding, if an object o invokes a method p, the JVM searches the implementation in classes C1, C2, ..., Cn-1, and ______.

Cn

In Java, the most general class is ______ class.

Object

Dynamic binding occurs at ______.

runtime

Overriding occurs when methods are not static, private, or ______.

final

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.

blank

Build a class that extends SpaceObject and provides its own ______ method implementation.

draw

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.

draw

Polymorphism enables you to deal in generalities and let the ______ handle the specifics.

execution-time environments

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.

inheritance

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

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.

natural

Method compareTo is declared in interface Comparable and is sometimes called the ______ comparison method.

natural

The sort call may specify as a second argument a Comparator object that determines an alternative ______ of the elements.

ordering

The Comparator interface is used for sorting a Collection’s elements in a different ______.

order

The static Collections method reverseOrder returns a Comparator object that orders the collection’s elements in ______ order.

reverse

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.

negative

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 ______.

inheritance

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 ______.

reuse

Primitive data types such as int, char, and float do not work with generics. For example, ______ is not allowed.

ArrayList

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.

element

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 ______.

Wrong!

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 ______.

inheritance

Learn how to create a new class that extends a base class, enabling the implementation of a custom draw method in a video game. Discover how polymorphism allows for seamless integration of new objects into existing code without modifying the screen manager. Get tips on leveraging polymorphism for efficient game development.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free
Use Quizgecko on...
Browser
Browser