CSC 205 Midterm

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

If a method in a subclass has the same signature as a method in the superclass the subclass method ________ the superclass method. a. overrides b. inherits c. implements d. overloads

a. overrides

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 a. Object b. String c. Scanner d. Animal

a. Object

In memory an array of String objects ________. a. consists of a set of variables each of which is a reference to a String object b. is compressed to four bytes for each element c. consists of an array of references to String objects d. must be initialized when the array is declared

c. consists of an array of references to String objects

A(n) _____________________ is an object that defines an unusual or erroneous situation that is typically recoverable. a. try block b. interface c. exception d. catch block e. error

c. exception

Which key word indicates that a class inherits from another class? a. super b. implements c. extends d. final

c. extends

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. a. scope resolution binding b. buffer overrun protection c. array bounds checking d. active array sequencing

c. array bounds checking

Which of the following is not a valid Java identifier? a. thirdNumber b. highest, c. anExtremelyLongIdentifierIfYouAskMe d. 2ndlevel e. answer_7

d. 2ndlevel

A polymorphic reference is one that can refer to _______________ type(s) of object(s). a. abstract b. static c. zero d. multiple e. exactly one

d. multiple

The ________ method removes an item from an ArrayList at a specific index. a. clear b. pop c. deleteAt d. remove

d. remove

A UML diagram does not contain ________. a. the class name b. the field names c. the method names d. the object names

d. the object names

When an object is passed as an argument to a method what is passed into the method's parameter variable? a. the class name b. the method names c. the values for each field d. the object's memory address

d. the object's memory address

Which modifier must be used in the declaration of a variable to make it a constant? a. static b. public c. void d. private e. final

e. final

________ refers to combining data and code into a single object. a. The constructor b. Data hiding c. Encapsulation d. Abstraction

c. Encapsulation

The ________ indicates the number of elements the array can hold. a. version of Java b. new operator c. array's data type d. array's size declarator

d. array's size declarator

In the following statement which is the interface? public class ClassA extends ClassB implements ClassC a. ClassB b. ClassA c. ClassC d. all are interfaces

c. ClassC

A constructor is a method that ________. a. never receives any arguments b. removes the object from memory c. performs initialization or setup operations d. returns an object of the class

c. performs initialization or setup operations

Which of the following is a correct method header for receiving a two-dimensional array as an argument? a. public static void passArray(int[], int[]) b. public static void passArray(int[1],[2]) c. public static void passArray(int [][]) d. public static void passArray(int[1,2])

c. public static void passArray(int [][])

When an array is passed to a method ________. a. a reference to the array is passed b. the method has direct access to the original array c. it is passed just as any other object would be passed d. All of these are true

d. All of these are true

Which of the following is the operator used to determine whether an object is an instance of a particular class? a. >> b. isa c. equals d. instanceOf

d. instanceOf

Two or more methods in a class may have the same name as long as ________. a. they have different return types b. they have different return types but the same parameter list c. You cannot have two methods with the same name. d. they have different parameter lists

d. they have different parameter lists

Software requirements specify ____________________. a. what a program should accomplish b. which programming language the developer should use c. how a solution should be implemented e) a programming schedule d. how objects should be encapsulated

a. what a program should accomplish

Which of the following exceptions are unchecked? a. IllegalAccessException b. RuntimeException c. NoSuchMethodException d. ClassNotFoundException

b. RuntimeException

____________________ is the automatic conversion between a primitive value and a corresponding wrapper object. a. Generating b. Static invocation c. Aliasing d. Autoboxing e. Number formatting

d. Autoboxing

In Java polymorphic references can be created through the use of __________________ and ________________. a. inheritance / abstract classes b. inheritance / interfaces c. interfaces / iterators d. interfaces / abstract classes

b. inheritance / interfaces

A subclass can directly access ________. a. only public and private members of the superclass b. only public and protected members of the superclass c. all members of the superclass d. only protected and private members of the superclass

b. only public and protected members of the superclass

It is common practice to use a ________ variable as a size declarator. a. static b. boolean c. final d. reference

c. final

Which task(s) is/are done in the implementation activity in the software development process? a. ensure that the program solves the targeted problem b. write the source code that will solve the problem c. determine how a program will accomplish its requirements d. all of the above e. specify what the program must accomplish

b. write the source code that will solve the problem

Which of the following will is considered a logical error? a. typing a curly bracket when you should have typed a parenthesis b. multiplying two numbers when you meant to add them c. forgetting a semicolon at the end of a programming statement d. misspelling an identifier e. dividing by zero

b. multiplying two numbers when you meant to add them

Consider the following inheritance hierarchy that is used in a video game. Character / \ Friend Villain / \ / \ WiseMan ShopKeeper Dragon Skeleton | | FlyingDragon EliteSkeleton Which of the following declaration and initialization will not cause a compiler error? a. Dragon d = new Villain(); b. Character c = new FlyingDragon(); c. FlyingDragon f = new Character(); d. Dragon d = new ShopKeeper();

b. Character c = new FlyingDragon();

Overloading means that multiple methods in the same class ________. a. perform the same function b. have the same name but different parameter lists c. have different names but the same parameter list d. have the same name but different return types

b. have the same name but different parameter lists

A subclass may call an overridden superclass method by ________. a. calling the superclass method first and then calling the subclass method b. prefixing its name with the super key word and a dot (.) c. using the extends key word before the method is called d. prefixing its name with the name of the superclass in parentheses

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

While ________ is centered on creating procedures ________ is centered on creating objects. a. procedural programming / class programming b. procedural programming / object-oriented programming c. object-oriented programming / procedural programming d. routine programming / method programming

b. procedural programming / object-oriented programming

________ refers to combining data and code into a single object. a. Abstraction b. The constructor c. Data hiding d. Encapsulation

d. Encapsulation

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? a. This code will result in a run-time error. b. The speak method defined in the Dog class will be called. c. The speak method defined in the Animal class will be called. d. The speak method will not be called at all. e. This code will result in a compile-time error.

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

If a class contains an abstract method ________. a. the method will only have a header but not a body and will end with a semicolon b. you must create an instance of the class c. the method cannot be overridden in subclasses d. All of these are true.

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

Which of the following is a named storage location in the computer's memory? a. a constant b. a variable c. an operator d. a literal

b. a variable

To indicate the data type of a variable in a UML diagram you enter ________. a. the variable name followed by a colon and the data type b. the variable name followed by the data type c. the data type followed by the variable name d. the class name followed by the variable name followed by the data type

a. the variable name followed by a colon and the data type

Big - Oh notation establishes a(n) ____________ on a growth function a. upper bound b. average (or mean) bound c. lower bound d. both a) and b) e. all of a) b) and c)

a. upper bound

Which of the following statements will correctly convert the data type if x is a float and y is a double? a. x = (float)y; b. x = y; c. x = <float> y; d. x = float y;

a. x = (float)y;

Most of the programming languages used today are ________. a. functional b. procedural c. object-oriented d. top-down

c. object-oriented

A(n) ________________ is a piece of data that we send to a method. a. expression b. object c. parameter d. service e. escape sequence

c. parameter

Which of the following best describes what happens when an object no longer has any references pointing to it? a. The object is overwritten the next time the new operator is called. b. The object is overwritten the next time the new operator is called using the same class. c. The object stays in memory for the remainder of the programs execution. d. The object is marked as garbage and its associated memory is freed when the garbage collector runs. e. The object is immediately deleted from memory.

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

What will be the results after the following code is executed? int[] x = { 55, 33, 88, 22, 99, 11, 44, 55, 66, 77 }; int a = 10; if (x[2] > x[5]) a = 5; else a = 8; a. a = 10 b. a = 8 c. a = 5 d. a = 13

a = 5

What type of relationship exists between two objects when one object is a specialized version of another object? a. "is a" b. "consists of" c. "contains a" d. "has a"

a. "is a"

Information is most likely to be lost in what kind of data conversion? a. A narrowing conversion b. A widening conversion c. assignment conversion d. promotion e. no information will be lost in any of the conversions listed above

a. A narrowing conversion

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? a. It will result in a compile-time error. b. It will call the speak method defined in the Animal interface. c. It will call the wagTail method defined in the Dog class. d. It will result in a run-time error.

a. It will result in a compile-time error.

Given the following two-dimensional array declaration which statement is true? int[][] numbers = new int[6][9]; a. The numbers array has 6 rows and 9 columns. b. The numbers array has 15 rows. c. The numbers array has 54 rows. d. The numbers array has 6 columns and 9 rows.

a. The numbers array has 6 rows and 9 columns

The Exception class and the Error class are subclasses of the ___________________ class. a. Throwable b. Catchable c. CompilerProblem d. RuntimeProblem

a. Throwable

If ClassC is derived from ClassB which is derived from ClassA this would be an example of ________. a. a chain of inheritance b. linear inheritance c. cascading classes d. multiple interfaces

a. a chain of inheritance

Which of the following ArrayList class methods is used to insert an item at a specific location in an ArrayList? a. add b. insert c. set d. store

a. add

Which of the following shows the inheritance relationships among classes in a manner similar to that of a family tree? a. flowchart b. class hierarchy c. CRC card d. UML diagram

a. class hierarchy

A class specifies the ________ and ________ that a particular type of object has. a. fields / methods b. relationships / object names c. fields / object names d. relationships / methods

a. fields / methods

Late binding is _______________ than _______________ . a. less efficient / compile-time binding b. less efficient / run-time binding c. more efficient / compile-time binding d. more efficient / run-time binding

a. less efficient / compile-time binding

A growth function that is O(n) is ____________________ a. linear b. logarithmic c. quadratic d. exponential e. constant

a. linear

When you work with a ________ you are using a storage location that holds a piece of data. a. primitive variable b. binary number c. numeric literal d. reference variable

a. primitive variable

A ________ member's access is somewhere between public and private. a. protected b. static c. final d. package

a. protected

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? a. snack = Fruit(4); b. snack = orange; c. Fruit.snack = orange; d. snack = Fruit.orange; e. snack =Fruit.last();

a. snack = Fruit.orange;

Which of the following describes the act of ensuring that a program solves the intended problem in all cases? a. implementing the design b. establishing the requirements c. preliminary practice coding d. testing e. creating a design

a. testing

When an "is a" relationship exists between objects the specialized object has ________. a. some but not all of the characteristics of the general object b. all of the characteristics of the general object plus additional characteristics c. some of the characteristics of the general class but not all plus additional characteristics d. none of the characteristics of the general object

b. all of the characteristics of the general object plus additional characteristics

A(n) ________ can be thought of as a blueprint that can be used to create a type of ________. a. cookie / cake b. class / object c. object / method d. object / class

b. class / object

In Java you do not use the new operator when you use a(n) ________. a. array size declarator b. initialization list c. two-dimensional array d. any of these

b. initialization list

Each array in Java has a public field named ________ that contains the number of elements in the array. a. limit b. length c. capacity d. size

b. length

Which of the following statements correctly specifies two interfaces? a. public class ClassA implements (Interface1, Interface2) b. public class ClassA implements Interface1, Interface2 c. public class ClassA implements Interface1 | Interface2 d. public class ClassA implements [Interface1, Interface2]

b. public class ClassA implements Interface1, Interface2

The scope of a public instance field is ________. a. inside the class but not inside any method b. the instance methods and methods outside the class c. inside the parentheses of a method header d. only the class in which it is defined

b. the instance methods and methods outside the class

In an inheritance relationship ________. a. the unified constructor always executes first regardless of inheritance b. the superclass constructor always executes before the subclass constructor c. the subclass constructor always executes before the superclass constructor d. the constructor with the lowest overhead always executes first regardless of inheritance in subclasses

b. the superclass constructor always executes before the subclass constructor

A partially filled array is normally used ________. a. with an accompanying parallel array b. with an accompanying integer value that holds the number of items stored in the array c. when you know how many elements will be in the array but not what the values are d. when only a very small number of values need to be stored

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

In the following statement which is the superclass? public class ClassA extends ClassB implements ClassC a. ClassA b. ClassC c. ClassB d. cannot tell

c. ClassB

____________ is the process of catching an exception in the chain of method calls from the method where the exception occurred up to the main method. a. Exception handling b. Finally block nesting c. Exception propagation d. Error handling e. Catch block nesting

c. Exception propagation

What would be the result after the following code is executed? int[] numbers = { 40, 3, 5, 7, 8, 12, 10 }; int value = numbers[0]; for (int i = 1; i < numbers.length; i++) { if (numbers[i] < value) value = numbers[i]; } a. The value variable will contain the sum of all the values in the numbers array. b. The value variable will contain the highest value in the numbers array. c. The value variable will contain the lowest value in the numbers array. d. The value variable will contain the average of all the values in the numbers array.

c. The value variable will contain the lowest value in the numbers array.

A ragged array is ________. a. a one-dimensional array for which the number of elements is unknown b. a two-dimensional array for which the number of rows is unknown c. a two-dimensional array where the rows have different numbers of columns d. a partially initialized two-dimensional array of ranged values

c. 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. a. super b. extends c. abstract d. final

c. abstract

The ________ method is used to insert an item into an ArrayList. a. store b. putItem c. add d. insert

c. add

All fields declared in an interface ________. a. must be initialized in the class implementing the interface b. have protected access c. are treated as final and static d. have private access

c. are treated as final and static

A _______________ is a list of characters in a particular order. Examples include ASCII and Unicode. a. character literal b. control character c. character set d. none of the above e. char data type

c. character set

Every line of a(n) __________________ is executed no matter what exceptions are thrown. a. catch block b. try block c. finally block d. interface e. call stack trace

c. finally block

When an object is created the attributes associated with the object are called ________. a. instance methods b. fixed attributes c. instance fields d. class instances

c. instance fields

A reference variable stores a(n) ________. a. binary encoded decimal b. object c. memory address d. string

c. memory address

The _____________ of an object defines its potential behaviors. a. white spacesname b. attributes c. methods d. variables e. name

c. methods

When two references point to the same object ________________________________ . a. a run-time error will occur. b. a compiler error will occur. c. the references are called aliases of each other. d. the references are called null references. e. the object will be marked for garbage collection.

c. the references are called aliases of each other.

Data hiding (which means that critical data stored inside the object is protected from code outside the object) is accomplished in Java by ________. a. using the private access specifier on the class definition b. using the private access specifier on the class methods c. using the private access specifier on the class fields d. using the public access specifier on the class methods

c. using the private access specifier on the class fields

What will be the result after the following code is executed? final int ARRAY_SIZE = 5; float[] x = float[ARRAY_SIZE]; for (i = 1; i <= ARRAY_SIZE; i++) { x[i] = 10.0; } a. A runtime error will occur. b. All the values in the array except the first will be set to 10.0. c. All the values in the array will be initialized to 10.0. d. The code contains a syntax error and will not compile.

d. The code contains a syntax error and will not compile. Correct code: final int ARRAY_SIZE = 5; float[] x = new float[ARRAY_SIZE]; for (int i = 0; i < ARRAY_SIZE; i++) { x[i] = 10; }

What is required for an interface method that has a body? a. All of these are true. b. A class that implements the interface must override the method. c. The @Default annotation must precede the method header. d. The method header must begin with the key word default.

d. The method header must begin with the key word default.

The commitment to execute certain code to carry out a method invocation is referred to as _________________. a. inheritance b. execution c. polymorphism d. binding

d. binding

When a method is declared with the ________ modifier it cannot be overridden in a subclass. a. public b. void c. Super d. final

d. final

In Java a(n) ___________________ is a collection of constants and abstract methods. a. implementation b. iterator c. abstract class d. interface e. polymorphic reference

d. interface

If the growth function for an algorithm is expressed as a polynomial then the asymptotic complexity of the algorithm is determined by the term with the ________________ . a. smallest exponent of the variable b. left most exponent c. largest coefficient of the variable d. largest exponent of the variable

d. largest exponent of the variable

Validating the results of a program is important to ________. a. correct syntax error b. create a model of the program c. correct runtime errors d. make sure the program solves the original problem

d. make sure the program solves the original problem

A reference variable stores a(n) ________. a. string b. object c. binary encoded decimal d. memory address

d. memory address

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. a. public b. static c. dynamic d. polymorphic

d. polymorphic

You can use the ________ method to replace an item at a specific location in an ArrayList. a. replace b. remove c. add d. set

d. set

Instance methods do not have the ________ key word in their headers. a. public b. private c. protected d. static

d. static

A(n) ________ is used as an index to pinpoint a specific element within an array. a. element b. argument c. boolean value d. subscript

d. subscript

The binary search algorithm ________. a. will normally have the number of comparisons that is half the number of elements in the array b. will have a maximum number of comparisons equal to the number of elements in the array c. is less efficient than the sequential search algorithm d. will cut the portion of the array being searched in half each time it fails to locate the search value

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

What does the following UML diagram entry mean? a. , setHeight(h ; double) ; void b. a private method with no parameters that returns a double data type c. a public field called setHeight that is a double data type d. a private field called setHeight that is a double data type e. a public method with a parameter of data type double that does not return a value

e. a public method with a parameter of data type double that does not return a value

A(n) ____________________ can be used to find the exact line where an exception was thrown during program execution. a. none of the above b. catch block c. interface d. try block e. call-stack trace

e. call-stack trace

Which of the following is a correct declaration of enumerated type for the suits of a deck of cards? a. enum Suit = { hearts, spades, diamonds, clubs } b. enumerated type Suit = { hearts, spades, diamonds, clubs }; c. enum Suit (hearts, spades, diamonds, clubs ); d. enumerated type Suit = {hearts, spades, diamonds, clubs }; e. enum Suit {hearts, spades, diamonds, clubs }

e. enum Suit {hearts, spades, diamonds, clubs } or enum Suit { hearts, spades, diamonds, clubs }

A(n) _____________________ is an object that defines an erroneous situation from which the program usually cannot recover. a. catch block b. interface c. try block d. exception e. error

e. error

Classes can be created from other classes by using _______________ . a. polymorphism b. machine code c. attributes d. encapsulation e. inheritance

e. inheritance

Regression testing refers to a. None of these describes regression testing b. running a program with many different sets of inputs. c. executing the program on many different types of computers and comparing the results. d. executing the statements in the program in reverse order. e. re-testing a program after fixing a problem to ensure that the fix worked and that it did not introduce another problem.

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


संबंधित स्टडी सेट्स

Wife of Bath's Tale, only answered questions i thought were important

View Set

Chapter 03 - Peripherals and Expansion

View Set

Normal Curve: Chapter 13 Personality

View Set

Med Surg II - Chapt 66 - Management of Pts with Neurologic Dysfunction

View Set

Compensation Chapter 11- Performance Appraisals

View Set

C.S. 150 Chapter 5 (Control Structures II (Repetition))

View Set

Chapter IV: How to Form a Business

View Set

Fresno State BIO 10 Homework 9: Lactose Intolerance

View Set