CECS 277 Final Review

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Aggregation

A 'has a' B relationship. B can exist without A.

Inheritance

A 'is-a' B relationship. Class B is derived from A.

Composition

A 'owns' B relationship. B cannot exist without A.

Dependency

A 'uses' B relationship.

Polymorphism

An object that can have multiple types.

Dynamic Binding

Create methods in superclass to override in the subclass

The keyword instanceof allows you to create an object of the type specified. (T/F)

False

When creating threads, you need to override the start() method. (T/F)

False

You should always add values to a BST in sorted order. (T/F)

False

A Vector is a type of set that allows you to preserve insertion order. (T/F)

False.

The ActionPerformed interface makes buttons clickable. (T/F)

False. ActionListener

Aggregation is the case where A 'has' B, and if A is destroyed, B is also destroyed. (T/F)

False. Aggregation = 'has a'. B can exist without A.

You need to close the scanner to save any changes to your file. (T/F)

False. Close the file.

Dependency is the case of A 'owns' B. (T/F)

False. Dependency = A 'uses' B

GUI stands for Global User Interface. (T/F)

False. It's GRAPHIC User Interface you nitwit.

To place an object into a HashSet, you are required to override compareTo() (T/F)

False. Override hashCode()

paintComponent() is used to place buttons and labels on your window. (T/F)

False. Panel is used to create and place buttons/labels

A map is used when uniqueness is required within your collection. (T/F)

False. Sets are used

Sorting algorithms that run at O(n^2) are faster than ones that are O(n log(n)). (T/F)

False. Speed of Big-O notation: O(1) - Constant O(long(n)) - Log O(n) - Linear O(n log(n)) - Log-Linear O(n^2) - Quadratic O(n^3) - Cubic O(2^n) - Exponential O(n!) - Factorial

Polymorphism is a variable of the subclass storing a reference to an object of the superclass. (T/F)

False. Superclass -> subclass

The List and Set interfaces extend the Collections interface. (T/F)

False. The List and Set interfaces IMPLEMENTS the Collections interface.

You can use a Scanner to write to a file. (T/F)

False. Use Printwriter

You can use a scanner to write to a text file. (T/F)

False. Use a Printwriter

Overriding

Methods with the same name as in its superclass

A FileInputStream reads bytes of data from a binary file. (T/F)

True

A Generic's type parameter is placed within angle brackets. (T/F)

True

A Heap keeps track of either the min or the max value at the root node. (T/F)

True

A method declared as abstract must be overriden. (T/F)

True

A polymorphic object cannot call methods of the subclass unless they are overridden. (T/F)

True

A subclass is extended from the superclass (T/F)

True

A try/catch block allows you to handle run time errors. (T/F)

True

All methods defined in an interface are automatically abstract. (T/F)

True

An abstract method is defined but not created. (T/F)

True

Any objects that will be sorted should implement Comparable. (T/F)

True

Binary Streams read and write single bytes to a file. (T/F)

True

Classes are made up of instance variables and methods. (T/F)

True

Dynamic binding makes methods in the superclass to override in the subclass. (T/F)

True

Encapsulation allows you to protect code and help make it reusable. (T/F)

True

IO streams are used to send messages between the Server and the Client. (T/F)

True

In a Map, all keys are unique. (T/F)

True

Multiple threads can share access to the same resources. (T/F)

True

Polymorphism is the term to describe when a variable is the data type of the superclass, but stores an object of the subclass. (T/F)

True

Serializable must be implemented in order to write an object to a binary file. (T/F)

True

Sockets are the means by which the Client and the Server are connected. (T/F)

True

The Collections class is a set of static methods for use on types of collections. (T/F)

True

The method drawString allows you to draw text on the window. (T/F)

True

Use the keyword 'extends' to inherit all data members and methods from the superclass to the subclass. (T/F)

True

When creating a new HashMap, you must specify two type arguments in <>. (T/F)

True

You can create objects from a class defined as final. (T/F)

True

You can create threads by extending Thread or implementing Runnable. (T/F)

True

You can use a scanner to read from a text file. (T/F)

True

You cannot create objects from a class declared as abstract. (T/F)

True

You must close a file when you are finished writing to it to save the changes. (T/F)

True

Interface

Specifies a behavior for a class.

If two different objects both hash to the same location, it is known as a __________. a. crash b. collision c. conflict d. clash

b. collision

Using a HashMap requires you to override the ______ method. a. compareTo() b. hashCode() c. comparable() d. getHash()

b. hashCode()

For a class to use an interface, it must use the keyword ________ a. extends b. implements c. interfaces d. references

b. implements

Lists are used when ___________ is (are) needed. a. hash codes b. indexing c. a key-value pair d. unique elements

b. indexing

The sleep method takes in the number of _____ it will sleep for. a. seconds b. milliseconds c. kiloseconds d. microseconds

b. milliseconds

Methods of an interface must be _______. a. inherited b. overriden c. downcasted d. dynamically bound

b. overriden

All methods in an interface are automatically created as _____ and ______. a. public, static b. public, abstract c. private, static d. private, abstract

b. public, abstract

A wildcard type can be constrained with a lower bound using the keyword _______. a. implements b. super c. constrain d. extends

b. super

Each node in a BST can have at most _____ child(ren). a. zero b. two c. one d. three

b. two

The symbol used for a wildcard is ______. a. # b. $ c. ? d. &

c. ?

If classes Dog and Cat extend abstract class Animal, which of the following will compile? a. Animal a = new Animal(); b. Dog d = new Animal (); c. Animal a = new Dog(); d. Cat c = new Animal();

c. Animal a = new Dog();

A class that extends ______ creates a window where components can be placed. a. AWT b. Swing c. JFrame d. JWindow

c. JFrame

To detect mouse clicks, the interface _____ must be implemented in the class. a. MouseMotionListener b. MousePressed c. MouseListener d. MouseClicked

c. MouseListener

Which interface needs to be implemented so an object of that class can be written to a file? a. Streamable b. Objectable c. Serializable d. Writable

c. Serializable

Maps are used when _______ is (are) needed. a. hash codes b. indexing c. a key-value pair d. unique elements

c. a key-value pair

Classes are used as a blueprint to make ______ of that type. a. methods b. statics c. objects d. variables

c. objects

A class extends ______ class(es), and implements ______ interface(s). a. zero to one, one to many b. zero to many, zero to one c. zero to one, zero to many d. zero to many, one to many

c. zero to one, zero to many

Using a TreeSet requires you to override the _____ method. a. compareTo() b. hashCode() c. comparable() d. getHash()

a. compareTo()

When one class inherits from another it must use the keyword _______. a. extends b. inherits c. abstract d. using

a. extends

To test the type of an object, you may use the keyword ______ a. instanceof b. getInstance c. classType d. getType

a. instanceof

Which of the following describes an 'Aggregation' relationship? a. 'is a' b. 'part of a' c. 'uses a' d. 'has a'

d. 'has a'

A ______ is used to receive a data stream. a. ServerSocket b. PrintStream c. Socket d. BufferedReader

d. BufferedReader

When constructing a PrintWriter, you must handle a _________ exception. a. UnknownFile b. NonExistantFile c. FileIO d. FileNotFound

d. FileNotFound

Which of the following is necessary to write an object to a binary file? a. ObjectReader b. ObjectSTream c. ObjectOutputReader d. ObjectOutputStream

d. ObjectOutputStream

To read from a text file, you need to declare a ______ first. a. Buffer b. Reader c. InputerFile d. Scanner

d. Scanner

The function _____ calls a thread's run method. a. wait() b. sleep() c. join() d. start()

d. start()

Sets are used when ______ is (are) needed. a. hash codes b. indexing c. a key-value pair d. unique elements

d. unique elements

A class may not use multiple generic type. (T/F)

False

A final class can be inherited. (T/F)

False

A method declared as final must be overriden. (T/F)

False

A networked connection cannot be multithreaded. (T/F)

False

A superclass is inherited from a subclass. (T/F)

False

A try/catch block cannot handle more than one type of exception at a time. (T/F)

False

BSTs always remove from the root. (T/F)

False

Generic methods may use a wildcard when passing in an unknown type. (T/F)

False

Methods can use the keyword 'locked' so only one thread can enter at a time. (T/F)

False

Private members of the superclass are accessible by the subclass. (T/F)

False

Final

This type of class cannot be inherited.

Abstract

This type of class cannot create objects.

Downcast

Typecasting an object as the subclass type.

A Server program allows incoming connections through a _______. a. ServerSocket b. PrintStream c. Socket d. BufferedReader

a. ServerSocket

To do File I/O, your program requires a ______ handler. a. FileReaderError b. FileNotFoundException c. FileExceptionError d. FileIOException

b. FileNotFoundException

A _______ is used to send a data stream. a. ServerSocket b. PrintStream c. Socket d. BufferedReader

b. PrintStream


Set pelajaran terkait

APES Unit 6: Energy Resources and Consumption

View Set

Perseverance and Making Sense: Through the Looking Glass

View Set

Final Exam for COMM 421 (T1, T2, T3)

View Set

Health Insurance Programs for Seniors Exam

View Set

Information Systems: Computer Networks

View Set