CSC205 Midterm

¡Supera tus tareas y exámenes ahora con Quizwiz!

What type of relationship exists between two objects when one object is a specialized version of another object?

"is a"

An accessor method accesses fields but may not modify a class' fields.

AKA Getter

If ClassC is derived from ClassB which is derived from ClassA, this would be an example of ________.

Chain of inheritance

A _______________ search is more efficient than a linear search.

binary

When a derived class defines a member method that has the same name, parameters, and return type as a base class's method, the member method is said to____________ the base class's method. The derived class takes precedence.

override

A ___________type variable directly stores the data for that variable type, such as int, double, or char. Ex: int numStudents = 20; declares an int that directly stores the data 20.

primitive

While ________ is centered on creating procedures, ________ is centered on creating objects.

procedural programming, object-oriented programming

One of the advantages of using generics is ________.

that more type problems can be uncovered at compile-time rather than at run time

When an object is passed as an argument to a method, what is passed into the method's parameter variable?

the objects memory address

Which task(s) is/are done in the implementation activity in the software development process?

write the source code that will solve the problem

If you want to share code among several closely related classes, expect that classes that extend your abstract class have many common methods or fields, or require access modifiers other than public (such as protected and private) or want to declare non-static or non-final fields.

Use abstract classes

Information is most likely to be lost in what kind of data conversion?

a narrowing conversion

A ragged array is ________.

a two-dimensional array where the rows have different numbers of columns

A class becomes abstract when you place the ________ key word in the class definition.

abstract

An_______________ is a class that guides the design of subclasses but cannot itself be instantiated as an object. Ex: An abstract Shape class might also specify that any subclass must define a computeArea() method.

abstract class

All fields declared in an interface ________.

are treated as final and static

Java performs ________, which means that it does not allow a statement to use a subscript that is outside the range of valid subscripts for the array.

array bounds checking

Which of the following is not a valid Java identifier?

2ndlevel

In the following statement, which is the interface? public class ClassA extends ClassB implements ClassC

ClassC

A __________ is a method input specified in a method definition. Ex: A pizza area method might have diameter as an input.

Parameter

A constructor is a method that _______

Performs initialization or setup operations.

A list node's data can store a record with multiple subitems.

TRUE

A method cannot modify an argument of primitive type. True False

TRUE

In a generic method, a type parameter is defined ________.

before the method's return type

The commitment to execute certain code to carry out a method invocation is referred to as _________________.

binding

A(n) ________ can be thought of as a blueprint that can be used to create a type of ________.

class, object

A wrapper class object (as well as a String object) is _________ meaning a programmer cannot change the object via methods or variable assignments after object creation

immutable,

A Java collection ________.

is an object that is used as a container for other objects

The three major categories of Java collections are ________.

lists, sets, and maps

Write a statement that converts the text representation of an integer within String numberText, storing the value in an int variable numLanes.

numLanes = Integer.parseInt(numberText)

If a method in a subclass has the same signature as a method in the superclass, the subclass method ________ the superclass method.

overrides

A(n) ________________ is a piece of data that we send to a method.

parameter

In Java, a reference variable is ________ because it can reference objects of types different from its own, as long as those types are related to its type through inheritance.

polymorphic

When you work with a ________, you are using a storage location that holds a piece of data.

primitive variable

An overriding method can call the overridden method by using the super keyword. Ex: super.getDescription(). The ________ is a reference variable used to call the parent class's methods or constructors.

super keyword

The scope of a public instance field is ________.

the instance methods and methods outside the class

A UML diagram does not contain ________.

the object names

When two references point to the same object, ________________________________

the references are called aliases of each other

A HashMap ________.

uses hash codes to store keys

Given the list (xlsx, xls, xlr, txt, ods), what is the order of the elements after completing insertion sort's second outer loop iteration?

xlr, xls, xlsx, txt, ods

Which of the following is a correct declaration of enumerated type for the suits of a deck of cards?

enum Suit {hearts, spades, diamonds, clubs }

Which key word indicates that a class inherits from another class?

extends

A derived class is declared by placing the keyword __________ after the derived class name, followed by the base class name. Ex: class DerivedClass _________ BaseClass { ... }.

extends, extends

Given the list (27, 40, 15, 25, 10, 19, 30), what are the new partitioned lists if the pivot is 25?

(10, 15, 19, 25) and (27, 30, 40)

Given the list (62, 45, 29, 32, 25, 10, 75), what is the list after sorting by the 1's digit?

(10, 62, 32, 45, 25, 75, 29)

To maintain a list in ascending sorted order, a given new item should be inserted at the position of the first element that is greater than the item.

True

You expect that unrelated classes would implement your interface. For example, the interfaces Comparable and Cloneable are implemented by many unrelated classes. You want to specify the behavior of a particular data type, but not concerned about who implements its behavior. You want to take advantage of multiple inheritance of type.

Use interface

A subclass can directly access ________.

only public and protected members of the superclass

A subclass may call an overridden superclass method by _______

prefixing its name with the super key word and a dot (.)

A _________type variable can refer to an instance of a class, also known as an object.

reference

Data hiding (which means that critical data stored inside the object is protected from code outside the object) is accomplished in Java by ________.

using the private access specifier on the class fields

Which of the following is a named storage location in the computer's memory?

variable

Software requirements specify _____________

what a program should accomplish

The binary search algorithm ____

will cut the portion of the array being searched in half each time it fails to locate the search value

A partially filled array is normally used ________

with an accompanying integer value that holds the number of items stored in the array

____________________ is the automatic conversion between a primitive value and a corresponding wrapper object.

autoboxing

Let Dog be a subclass of Animal, and suppose Animal has a method called speak() that is overridden in the Dog class. Consider the following code. Animal spot = new Dog();spot.speak(); Which of the following is true?

The speak method defined in the Dog class will be called.

Identify the correct sequence of performing a binary search.

1. Binary search first checks the middle element of the list. 2. If the search key is not found, the algorithm: i. checks the left sublist if the search key is less than the middle element or ii. checks the right sublist if the search key is greater than the middle element.

Assume an ordered list containing the English alphabet. Using linear search, how many letters are checked to locate the letter "K"?

11

The array (67, 23, 32, 80, 53, 60) is to be sorted using selection sort. What is the order of the elements after the third swap?

23, 32, 53, 80, 67, 60

Which of the following ArrayList class methods is used to insert an item at a specific location in an ArrayList?

add

When an "is a" relationship exists between objects, the specialized object has ________.

all of the characteristics of the general object plus additional characteristics

The ___________________ algorithm sorts values by repeatedly comparing neighboring elements in the list and swapping their position if they are not in order relative to each other.

bubble sort

Which of the following shows the inheritance relationships among classes in a manner similar to that of a family tree?

class heirarchy

The notation < E extends Comparable > ________.

declares a generic type that implements the Comparable interface

A method's local variables are ___________ from memory upon a method's return; each new call creates new local variables in memory.

discarded

Each constructed class object creates a new instance of a static field.

false

A class specifies the ________ and ________ that a particular type of object has.

fields, methods

It is common practice to use a ________ variable as a size declarator

final

Which modifier must be used in the declaration of a variable to make it a constant?

final

In Java, you do not use the new operator when you use a(n) ________.

initialization list

When an object is created, the attributes associated with the object are called ________.

instance fields

In Java, a(n) ___________________ is a collection of constants and abstract methods.

interface

The _____________ of an object defines its potential behaviors.

methods

A polymorphic reference is one that can refer to _______________ type(s) of object(s).

multiple

Which of the following will is considered a logical error?

multiplying two numbers when you meant to add them

A ________ member's access is somewhere between public and private.

protected

Which of the following statements correctly specifies two interfaces?

public class ClassA implements Interface1, Interface2

Which of the following is a correct method header for receiving a twodimensional array as an argument?

public static void passArray(int [][])

Regression testing refers to

re-testing a program after fixing a problem to ensure that the fix worked and that it did not introduce another problem

The ________ method removes an item from an ArrayList at a specific index.

remove

You can use the ________ method to replace an item at a specific location in an ArrayList.

set

Fruit is an enumerated type with values apple, banana, grape, and orange, in that order. Which of the following statements assigns the value orange to the Fruit variable snack?

snack = Fruit.orange;

Instance methods do not have the ________ key word in their headers.

static

A(n) ________ is used as an index to pinpoint a specific element within an array

subscript

The ________ keyword is a reference variable used to call the parent class's methods or constructors.

super

If a class contains an abstract method ________.

the method will only have a header, but not a body, and will end with a semicolon

In an inheritance relationship ________.

the superclass constructor always executes before the subclass constructor

To indicate the data type of a variable in a UML diagram, you enter ________.

the variable name followed by a colon and the data type

You need to create a reference variable that can refer to objects from many different classes. You do not know the inheritance hierarchies of the classes. The safest class to use to declare the reference variable is

Object

A class' public static fields can be accessed outside the class because the fields are public. But, a private field can only be accessed by the class' methods.

true

A public static field can be accessed outside of the class using dot notation.

true

__________ refers to determining which program behavior to execute depending on data types

Polymorphism

_________(expression) { case value1 : // Statements break; // break is optional case value2 : default : // Statements }

Switch

A method is visible to all other methods defined in the same class regardless of the order in which the methods were defined.

TRUE

A parameter of reference type allows a method to access the class members of the object to which the parameter refers.

TRUE

What is required for an interface method that has a body?

The method header must begin with the key word default.

A list of 10 elements is to be sorted using insertion sort algorithm. How many times will the outer loop be executed?

9

A mutator method may modify ("mutate") a class' fields

AKA Setter

A class that provides default variables.

Abstract

An __________is a method that is declared without an implementation (without braces, and followed by a semicolon)

Abstract method

_____________ means to have a user interact with an item at a high-level, with lower-level internal details hidden from the user

Abstraction

An __________ is a value provided to a method's parameter during a method call. Ex: A pizza area method might be called as printPizzaArea(12.0) or as printPizzaArea(16.0).

Argument

The ________ indicates the number of elements the array can hold.

Array's size declarator

________ is the automatic conversion of primitive types to the corresponding wrapper classes. ____________ is the automatic conversion of wrapper class objects to the corresponding primitive types.

Autoboxing, Unboxing

can be used to sort the same set of objects in multiple ways

Comparator objects

________ refers to combining data and code into a single object

Encapsulation

________ refers to combining data and code into a single object.

Encapsulation

___________ allows one class (a subclass) to be based on another class (a base class or superclass). Ex: A Shape class may encapsulate data and behavior for geometric shapes, like setting/getting the Shape's name and color, while a Circle class may be a subclass of a Shape, with additional features like setting/getting the center point and radius.

Inheritance

A class that provides only static final fields.

Interface

Suppose Animal is an interface that specifies a single method - speak. Now suppose the Dog class implements the Animal interface. In addition to the speak method, the Dog class also has a method called wagTail. Now consider the following code. Animal a = new Dog();a.wagTail(); Which of the following is true about this code?

It will result in a compile-time error.

The concrete classes that implement the List interface are ________.

LinkedList and ArrayList

Which is the worst case runtime for a quicksort algorithm?

O(N ^2)

Which of the following is a fast sorting algorithm?

Quicksort

Which sorting technique does not compare two values and then sort the values?

Radix sort

Which of the following best describes what happens when an object no longer has any references pointing to it?

The object is marked as garbage and its associated memory is freed when the garbage collector runs.

A Set holds a unique group of values/objects.

True

When an array is passed to a method

a reference to the array is passed, it is passed just as an object and the method has direct access to the original array

An _______--- is a method that is not implemented in the base class, thus all derived classes must override the function. An abstract method is denoted by the keyword abstract in front of the method signature.

abstract method

The ________ method is used to insert an item into an ArrayList.

add

A _______________ is a list of characters in a particular order. Examples include ASCII and Unicode

character set

A _________is a class that is not abstract, and hence can be instantiated.

concrete class

In memory, an array of String objects ________.

consists of an array of references to String object

When a method is declared with the ________ modifier, it cannot be overridden in a subclass.

final

In the declaration ArrayList, T is a(n) _________.

generic type

Overloading means that multiple methods in the same class ________.

have the same name but different parameter lists

Classes can be created from other classes by using _______________ .

inheritance

In Java, polymorphic references can be created through the use of __________________ and ________________.

inheritance, interface

The __________________ algorithm sorts a list of values by repetitively inserting a particular value into a subset of the list that has already been sorted.

insertion sort

Which of the following is the operator used to determine whether an object is an instance of a particular class?

instanceOf

Declare and initialize a two dimensional array of integers named dataVals with 4 rows and 7 columns using default element values

int[][] dataVals = new int[4][7];

In a binary search, _______________________________ .

it is assumed that the search pool is ordered

In selection sort, the smallest element is selected and swapped with the _____ unsorted element.

leftmost

Each array in Java has a public field named ________ that contains the number of elements in the array

length

Late binding is _______________ than _______________ .

less efficient, compile-time binding

A __________________ search looks through the search pool one element at a time.

linear

A _________ stores an ordered list of items. The links in each node define the order in which items are stored.

linked list

The ArrayList implements what collections interface?

list

Which of the following describes the act of ensuring that a program solves the intended problem in all cases?

testing

Two or more methods in a class may have the same name as long as ________

they have different parameter lists

UML uses an arrow with a solid line and an unfilled arrow head to indicate that one class inherits from another. The arrow points toward the superclass.

true

Validating the results of a program is important to ________.

make sure the program solves the original problem

a reference variable stores a

memory address


Conjuntos de estudio relacionados

System Analysis and Design Chapters 4, 5, 6 review

View Set

BUS 346 Chapter 10, BUS 346 Ch 8, chapter 8 marketing, Exam 3

View Set

chapter 10 (psychology of aging)

View Set

German tenses (Present, Past, Future + "can" with 'ich')

View Set

Chapter 6: Learning - Application

View Set