CSC 223 - Data Structures & Algorithms // Concept Final Review

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

list

a collection that exhibits a linear relationship among its elements

nodes

a data structure that stores a value that can be of any data type and has a pointer to another node

inheritance

a feature of object-oriented programming, where classes contain all variables and methods defined in their supertypes

this reference

a reference to an object that is passed to any object's non-static class method

data structure

a single entity that contains a collection of information

constructor

a special non-static method that creates an object of the class and can assign default values to instance variables

stack

a structure which elements are added and removed from only one end; a "Last In, First Out" (LIFO) structure

aggregation

a type of containment in which a class contains one or more members of another class that could continue to exist without the object that contains them

array

a type of data structure

Why is it a good design principle to have a method throw an exception when it cannot accomplish its task instead of simply ignoring the task or having the method end without making any changes? a) making a method throw an exception when it cannot accomplish its task requires this method to be called in a try/catch block which means that this potential exception is known to the calling program and it can take the appropriate action b) ignoring the task is bad and can cause the program to crash c) because throwing an exception is easy and it should always be done d) not making changes is much worse and can cause errors in the program

a) making a method throw an exception when it cannot accomplish its task requires this method to be called in a try/catch block which means that this potential exception is known to the calling program and it can take the appropriate action

___ refers to determining which program behavior to execute depending on data types. a) Polymorphism b) Inheritance c) Overriding d) Overloading

a) Polymorphism

A local restaurant starts losing customers to a new restaurant that opened nearby. This restaurant needs less waiters because it has less customers. The restaurant decides to value the employees that have been with the company the longest. They will start by laying off the employee with the least time with the company. If that is not enough then they will layoff the employee with second least time with the company. They will continue this until they have as many waiters as they need for the reduced number of customers. Which Abstract Data Type (ADT) would you use to allow the restaurant to work in this way? a) Stack b) Queue c) Tree d) List

a) Stack

Which of the following is the term for when a method or constructor has the same name as another method or constructor but has different set of parameters or unique signature? a) overloading b) inheritance c) non-static method d) overriding

a) overloading

Which of the following is the term for when a child class replaces a method it inherits from its parent class with its own definition, but has the same signature as the method it received from its parent class? a) overriding b) constructor c) overloading d) non-static method

a) overriding

What is the relationship between a type parameter and a type argument? a) type argument sends a data type to the type parameter b) type argument sends a data value to a type parameter c) type parameter sends a data type to the type argument d) type parameter sends a data value to the type argument

a) type argument sends a data type to the type parameter

abstract data type

an entity that is defined by how it functions and not by how it is implemented or constructed

object

an example or instance of a class

immutable object

an object that once instantiated cannot be changed

Which of the following is a set of requirements for a class to implement? a) Class b) Interface c) Exception class d) Object

b) Interface

The Stack Abstract Data Type (ADT) and Queue Abstract Data Type (ADT) differ in the way that items are added and removed from them. Which of the following statements is true? a) Stack adds items to the top and removes them from the bottom b) Queue adds items to the rear and removes them from the front c) Stack adds items to the bottom and removes them from the top d) Queue adds items to the front and removes them from the front

b) Queue adds items to the rear and removes them from the front

A derived class method with the same name, parameters, and return type as a base class method is said to _____ the base class's method. a) overload b) override c) copy d) inherit

b) override

Which of the following does the keyword super refer to in Java? a) a public method in the parent class b) the parent class c) the constructor of the parent class d) the child class

b) the parent class

class

blueprint, model, or definition for creating objects

We have learned about abstract data types and specifically how to implement them in two different ways. One approach is to use an array and the other approach is to use nodes. Which of the following is an accurate description of the array based approach? a) It allows for the size of an abstract data type to not be limited and can grow as large as needed during the execution of the program. b) It uses dynamic allocation of memory such that the amount of memory that is reserved changes during the execution of the program. c) It uses static allocation of memory which means that the amount of memory that is reserved does not change as the program executes, but rather the amount of memory is either determined when the program is written or when the program allocates memory. d) It requires the creation of a Node class that allows for the creation of objects that are able to connect each other to form a data structure.

c) It uses static allocation of memory which means that the amount of memory that is reserved does not change as the program executes, but rather the amount of memory is either determined when the program is written or when the program allocates memory.

If a queue is implemented as a linked list, an enqueue inserts a new item _____. a) before the first item b) before the last item c) after the last item d) after the first item

c) after the last item

Given a stack myData: Tom, Sam (top is Tom), what is the output after the following operations? Push(myData, Hal) Pop(myData) Pop(myData) Pop(myData) print(Pop(myData)) a) Hal b) Sam c) null d) Tom

c) null

pipe (|) operator

checks every part of the condition. This differs from || which will check in sequence and if any condition in sequence if found to be true, then II stops further checking.

Which of the following can best be described as an entity that is defined by how it functions and not by how it is implemented or constructed? a) Class b) Concrete Data Type c) Data Structure d) Abstract Data Type

d) Abstract Data Type

You are a software developer put in charge of developing a prototype for software that would be used in a doctor's office. The doctor's staff currently gives each patient a piece of paper with a number on it when they arrive. When the patient's number is called that patient is seen by the doctor. Patients that arrive earlier are seen by the doctor sooner and their number is lower than patients who arrive later. Your task is to develop software that will model this process without the need for pieces of paper and the patients will be seen in the order they would have been seen under the old system. Which Abstract Data Type (ADT) would you use to store the patients so that they are seen in the correct order? a) Tree b) List c) Stack d) Queue

d) Queue

What does a child class inherit from it parent class in Java? a) it doesn't inherit anything from its parent class b) everything that is private in its parent class c) everything that is public or private in its parent class d) everything that is public in its parents class

d) everything that is public in its parents class

Which of the following is an example or instance of a class in object-oriented programming? a) class b) non-static method c) instance variable d) object

d) object

In a queue, a dequeue operation always removes _____ element. a) a random b) the back c) the middle d) the front

d) the front

composition

describes the relationship between classes when one class object is a data field in another class. Also sometimes more specifically a containment relationship between classes when an object of the contained class would cease to exist without the containing class. (has - a relationship)

overloading

describes using one term to indicate diverse meanings. or writing multiple methods with the same name but different arguments

dequeue

elements can be removed from the front of the queue

queue

elements enter at one end and are removed from the opposite end

static variable

is the same for all instances or objects of a class. Static variables belong to the class itself as a whole and not to the objects of a class.

data type

kind of information that can be stored in a variable

static memory allocation

memory is allocated for declared variables by the compiler

non-static methods

methods that must be called on an instance of a class methods used with object instantiations

enqueue

new elements can be added to the rear of the queue

overriding

occurs when a subclass (child class) has the same method as the parent class

generics

parameterized types; allow us to define a set of operations that manipulate objects of a particular class, without specifying the class of the objects being manipulated until a later time

add

puts an element to the list

entity

something that exists independently

abstract

something that only exists as an idea

remove

takes an element off the list

polymorphism

the ability of an object to take many forms

encapsulation

the act of hiding data and methods within an object

dynamic memory allocation

the process of assigning the memory space during the execution time or the run time

instance variable

there is one copy of each instance variable for each object of a class


Conjuntos de estudio relacionados

Chapter 7: Managing Files (Review Questions)

View Set

WGU Principles of Psychology, D167

View Set

Pathophysiology chapter 17 Control of Cardiovasvular Function

View Set

Chapter 3: Solving Problems by Searching

View Set