COP 3330 Final Exam

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

Set

A collection that cannot contain duplicate elements

Sorted Map

A map that maintains its mappings in ascending key order

Regarding classes, instance variables are _______________. A) Non-Static B) Static C) Both A and B D) None of the above

A) Non-static

List

An ordered collection

Parameters are different than arguments because arguments are used when ______________. A) A class is defined B) A method or constructor is called C) A method or constructor is defined D) An abstract class is defines E) An interface is defined

B) A method or constructor is called

How many superclasses can a subclass extend when using inheritance in object-oriented programming using the Java programming language? A) Zero B) One C) Two D) Three E) Unlimited

B) One

Does the following code include all required components for a method declaration? void thisMethod() { } A) No, it's missing the access modifier B) Yes C) No, it's missing the return type D) No, it's missing the argument list E) No, it's missing the parameter list

B) Yes

When does a method return to the code that invoked it? A) Reaches a return statement B) Throws an exception C) Completes all the statements in the method D) A or B E) A, B or C

E) A, B or C

The ternary operator takes three operands and uses the (?:) notation. What control structure does the ternary operator mimic? A) Switch B) While loop C) For loop D) Do/while loop E) If/else

E) If/else

(T or F) Access level modifiers do not define how other classes can reference a field or invoke a method.

F

(T or F) Collections cannot be converted to traditionally arrays.

F

(T or F) Primitive data types can be used as parameters to a generic method.

F

What Java interfaces does the DOM define?

Text Element Node Attr Document

Collection

The root of the collection hierarchy

(Yes or No) If a class includes a static method, is it required to create an instance of the class to use the method?

Yes

@param [argument name] [argument description]

describes an argument of method or constructor

@author [author name]

identifies author(s) of a class or interface

@version [version]

version info of a class or interface

What is the most current/recent version of XML when used in an XML document in the <!DOCTYPE> statement?

1.0

In object-oriented terms what is used as a blueprint to model a real-world object? A) Method B) Class C) State D) Constant E) Behavior

B) Class

A(n) _____________ comprises variables, operators, and method invocations. A) Statement B) Expression C) Abstract class D) Class E) Interface

B) Expression

What are the components of a method declaration that comprise the method signature? A) Method return type and method name B) Method name and method parameter list C) Method return type, method name, and method parameter list D) Method return type and method parameter list E) All of the above

B) Method name and method parameter list

The keyword this is used to reference _____________. A) The class's destructor B) The current object C) The subclass D) The interface E) The inheritance

B) The current object

Which of the following is NOT one of the ways to traverse collections? A) using Iterators B) the for-each construct C) individual operations D) aggregate operations

C) individual operations

To create a constant, what is the correct implementation? A) public final int NOON = 12; B) public static final NOON = 12; C) public static final int NOON = 12; D) public static int NOON = 12;

C) public static final int NOON = 12;

For our Assignment 4 we are using the DOM parser, what does DOM stand for?

Document Object Model

Variable naming has rules associated with it. Which of the following is true? A) They can start with a number B) They can start with any special character C) They can include white space D) All of the above E) None of the above

E) None of the above

Does the following code include all required components of a class declaration? class NewClass { } A) No, it's missing the fields and methods B) No, the access modifier is required C) No, it's missing the return type D) No, it's missing the parentheses and parameter list E) Yes

E) Yes

(T or F) Regarding object-oriented programming, declaration means that a variable name is associated with an object type and it creates an object of that type.

F

(T or F) The following code is an example of defining a generic class. public interface Pairs <K, V> { public K getKey(); public V getValue(); }

F

A collections framework is a unified architecture for representing and manipulating collections. Which of the following do all collections frameworks contain?

Interfaces Implementations Algorithms

Node.getAttribute(attrName)

Returns the attribute with the requested name for a given node

Node.getFirstChild()

Returns the first child of a given node

private

can only be accessed in its own class

protected

can only be accessed within its own package; can be accessed by a sublcass of its class in another package

public

visible to all classes everywhere

Sorted Set

A set that maintains its elements in ascending order

What does the keyword final indicate regarding methods or field members of a class? A) They are private B) They are modifiable C) They are public D) They cannot be modified E) None of the above

D) They cannot be modified

Access level modifiers define what? A) how to use the Java API B) how packages interact with each other C) how projects interact with each other D) how other classes can reference a field or invoke a method

D) how other classes can reference a field or invoke a method

Regarding operator precedence which of the following would be evaluated first? A) = B) * C) + D) instanceof E) ++

E) ++

(T or F) Regarding object-oriented programming, when an object is instantiated the keyword new is used, memory is allocated, and a reference to that memory is returned.

T

package-private

visible only within its own package

What comment annotation MUST be used for code comments to be used as Javadoc data?

/** .... */

There are specific steps associated with parsing an XML file. Please select the correct order for a successful XML file parse experience.

1. Import XML-related packages 2. Create DocumentBuilder 3. Create a Document from a file or stream 4. Extract the root element 5. Examine attributes 6. Examine sub-elements

Regarding the return type of a method, which of the following would be valid? > subclass of the specified class return type > void > class > leave it empty (e.g. public setData(int data)) > interface > primitive data type (e.g. int, float, boolean)

> subclass of the specified class return type > void > class > interface > primitive data type (e.g. int, float, boolean)

What is Javadoc? Select all that apply. > write basic Javadoc comments > how to use features of Javadoc to generate text file documentation > a tool that generates HTML documentation from Javadoc comments in the code > a tool that generates MS Word documentation from Javadoc comments in the code > how to use features of Javadoc to generate HTML documentation

> write basic Javadoc comments > a tool that generates HTML documentation from Javadoc comments in the code > how to use features of Javadoc to generate HTML documentation

Deque

A collection used to hold multiple elements prior to processing, all new elements can be inserted, retrieved and removed at both ends

Queue

A collection used to hold multiple elements prior to processing, the head of the queue is the element that would be removed by a call to remove or poll

Which of the following is not a valid comment that would result in Javadoc generation? A) // The following code does the following... B) /** Class Description of MyClass */ C) /** Constructor Description of MyClass() */ D) /** Field Description of myIntField */

A) // The following code does the following...

If a method is declared with a return type other than void, where in the method body is the data returned? A) Anywhere in the body of the method B) Not required C) Must be the very last statement D) Must the be the very first statement

A) Anywhere in the body of the method

A method in object-oriented programming can return primitive data types, _____________, or _____________. A) Class, interface B) Function, method C) Project, package D) Constructor, exception E) Code, return

A) Class, interface

A(n) _____________ forms a complete unit of execution to include a terminating semicolon. A) Expression statement B) Expression C) Class D) Interface E) Abstract class

A) Expression statement

Object-oriented programming allows for inheritance so commonly used to state and behavior can be reused. The class that is inherited from is the _______________ and the new class is the _______________. A) Superclass, subclass B) Subclass, superclass C) Interface, subclass D) Class, package E) Extends, implements

A) Superclass, subclass

What is the purpose of control flow statements? A) To allow programs to run with a break up of execution flow B) To allow programs to run sequentially C) To allow programs to run line by line from top to bottom D) All of the above E) None of the above

A) To allow programs to run with a break up of execution flow

Regarding methods of classes, which of the following is NOT one of the the three ways a method returns to the code that invoked it? A) encounters a continue statement B) throws an exception C) completes all the statements in the method D) reaches a return statement

A) encounters a continue statement

Given the following generic class definition public class GenericBox<T> { } When declaring a variable that uses a generic class like below GenericBox<Integer> integer; replaces T with some concrete value, what is this called? A) generic type invocation B) interface implementation C) parameterized type D) type argument

A) generic type invocation

What is a collection? A) is an object that groups multiple elements into a single unit B) is an object that groups single element into a multiple units C) exactly the same as an array D) is an object that groups multiple elements into a multiple units

A) is an object that groups multiple elements into a single unit

Using the keyword this has multiple uses in OOP. Which of the following is NOT a correct usage? A) refer to a subclass of the class B) in a constructor use this to call another constructor in the same class C) field is shadowed by a method or constructor parameter D) referencing the current object

A) refer to a subclass of the class

When defining a generic class, the class name is followed by diamond brackets (<>). What is this called? A) type parameters B) class return type C) interface arguments D) method return type

A) type parameters

Map

An object that maps keys to values

If a class explicitly declares a constructor that takes 0...n parameters when instantiated what happens to the default constructor of the class? A) It still exists and can be used to create instances of the class B) It no longer exists C) It is automatically created by the Java compiler D) All of the above E) None of the above

B) It no longer exists

Regarding file pathing there are two options, absolute and relative. Which of the following statements is true? A) Absolute never includes the root element and the complete directory list required to access the file B) Relative needs to be combined with another path to access the file C) Absolute needs to be combined with another path to access the file D) Relative always includes the root element and the complete directory list required to access the file E) There is no difference

B) Relative needs to be combined with another path to access the file

When using static fields in a class, how many instances of the field exists when creating a minimum of 10 objects of the class? A) none B) every instance of the class shares a class variable in one fixed location in memory C) the same number of created objects (i.e. if 10 objects are created then there are 10 instances of the static field) D) half of the number of created objects (i.e. if 10 objects created, there are 5 of the static fields)

B) every instance of the class shares a class variable in one fixed location in memory

What is a key difference between if/else and switch control flow? A) switches stop evaluating when it finds a true condition B) if/else stops evaluating when it finds a true condition C) Both stop evaluating when it finds a true condition D) if/else continues evaluating after it finds a true condition E) None of the above is true, there is no difference

B) if/else stop evaluating when it finds a true condition

Explicit constructor invocation refers to what OOP practice? A) to call the abstract class's constructor B) in a constructor use this to call another constructor in the same class C) to call the superclass's constructor D) to call the subclass's constructor

B) in a constructor use this to call another constructor in the same class

A(n) ____________ declares a variable. A) Expression statement B) Expression C) Declaration statement D) Class E) Interface

C) Declaration statement

What does XML stand for? A) Extensible Madeup Language B) Extended Madeup Language C) Extensible Markup Language D) Extended Markup Language

C) Extensible Markup Language

What does "parsing" mean relative to XML Parsing? A) To copy an XML file and create a new one from the read in data B) Writing a new XML file C) Parsing XML refers to going through XML document to access data or to modify data in one or other way D) To delete all the data in an XML file

C) Parsing XML refers to going through XML document to access data or to modify data in one or other way

When method parameters have the same name as class fields this is called _____________. A) Repetition B) Same name C) Shadowing D) Duplication E) Confusion

C) Shadowing

When using inheritance what does the new class inherit when it is derived from another class? A) Object, class B) Function, method C) State, behavior D) Project, package E) Inheritance, interface

C) State, behavior

Local variables store a ___________ state. A) Instance B) Static C) Temporary D) Permanent E) None of the above

C) Temporary

Regarding conditional operators (i.e. &&, ||) what does "short circuiting" behavior mean? A) Only the second operand/expression is evaluated B) Only the first operand/expression is evaluated C) The second operand/expression is evaluated if needed D) Both operands/expressions are evaluated E) None of the operands/expressions are evaluated

C) The second operand is evaluated if needed

Operators are special symbols that perform specific operations on up to how many operands? A) One B) Two C) Three D) Four E) None

C) Three

Static fields in a class are also know as __________. A) instance variables B) member variables C) class variables D) constants

C) class variables

What operator is used to annotate a generic interface? A) {} ~ curly operator B) >< ~ diamond operator C) [] ~ bracket operator D) <> ~ diamond operator

D) <> ~ diamond operator

Parameters are different than arguments because parameters are used when _______________. A) An interface is defined B) A method or constructor is called C) A class is defined D) A method or constructor is defined E) An abstract class is defined

D) A method or constructor is defined

What allows for methods to have the same name but different method signatures in object-oriented programming? A) Return type B) Access modifier C) Argument list D) Parameter list E) None of the above, this is not permitted

D) Parameter list

Encapsulation of class fields hides implementation details. How is encapsulation used to access fields of classes? A) Private methods are written to interact with the private fields B) Public methods are written to interact with the public fields C) Private methods are written to interact with the public fields D) Public methods are written to interact with the private fields E) None of the above, encapsulation is not a real topic in object-oriented programming

D) Public methods are written to interact with the private fields

What is used as keywords recognized by Javadoc which define the type of information that follows. A) Tag elements B) Nodes C) Elements D) Tags

D) Tags

What does the instanceof operator do? A) Tests if the compared operands are identical B) Tests if the compared operands are equal C) Tests if the expression is true D) Tests if the object is an instance of a class, subclass, or implements an interface E) Tests if the expression is false

D) Tests if the object is an instance of a class, subclass, or implements an interface

When having to programmatically differentiate a parameter having the same name as a field of a class what keyword can resolve this issue with the compiler when setting the field value equal to the argument value passed into the method? A) parameter B) keyword C) in D) this E) argument

D) this

If there are an unknown number of parameters being passed to a method a software developer can use a construct called ______________. A) an array B) a 2-D array C) an ArrayList D) varargs E) None of the above

D) varargs

Document Object Model is an official recommendation of the World Wide Web Consortium (W3C). As software developers, what does that do for us?

Defines an interface that enables programs to access and update the style, structure, and contents of XML documents

By convention, type parameter names are single, uppercase letters, so that it is easy to tell the difference between a type variable and an ordinary class or interface name. E = K = V = N = T =

E = Element K = Key V = Value N = Number T = Type

Node.getLastChild()

Returns the last child of a given node

Node.getNextSibling()

Returns the next sibling of a given node

Node.getPreviousSibling()

Returns the previous sibling of a given node

Document.getDocumentElement()

Returns the root element of the document

(T or F) A class can have multiple constructors.

T

(T or F) An expression statement forms a complete unit of execution with a terminating semicolon. The following code is a correct example of an expression statement: Game game = new Game();

T

(T or F) Can generics be used when defining classes?

T

(T or F) Polymorphism refers to a principle in biology in which an organism or species can have many different forms or stages.

T

(T or F) The following code is an example of defining a generic class: public class GenericBox<T> { // T stands for "Type" private T t; public void set(T t) { this.t = t; } public T get() { return t; } }

T

(T or F) When using explicit constructor invocation the invocation of another constructor MUST be the first line in the constructor

T

What are advantages of using XML?

Technology agnostic Allow Validation Extensible Human readable

What are the disadvantages of using XML?

Verbose Redundant Syntax

Which of the following are true regarding XML? Select all that apply. o XML is a tag based language like HTML o XML tags are not designed to be self descriptive o XML tags are predefined like HTML o XML is a simple text based language o XML is a markup language o XML was designed to store and transport data in plain text format.

XML is a tag based language like HTML XML is a simple text based language XML is a markup language XML was designed to store and transport data in plain text format

@return [description of return]

describes data returned by method (unnecessary for constructors and void methods)

@exception [exception thrown] [exception description]

describes exception thrown by method

@throws [exception thrown] [exception description]

same as @exception


Conjuntos de estudio relacionados

Chapter 20: Short-Term Financial Planning

View Set

OWare- Earth And Space Science 8. Earth's Water

View Set

BRUNNERS - Ch 67 - Management of Patients with Cerebrovascular Disorders

View Set

Chapter 8: Overview of the micronutrients & phytochemicals

View Set

Honors World History 9: Ancient Greece

View Set

Lesson 19 Geography of Ancient China

View Set