CSC-Qz9

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What does the following code do? Assume list is an array of int values, temp is some previously initialized int value, and c is an int initialized to 0. for (j=0; j < list.length; j++) if (list[j] < temp) c++; a) It finds the smallest value and stores it in temp b) It finds the largest value and stores it in temp c) It counts the number of elements equal to the smallest value in list d) It counts the number of elements in list that are less than temp e) It sorts the values in list to be in ascending order

It counts the number of elements in list that are less than temp

Which statement is completely true? a) Java upcasts automatically, but you must explicitly downcast b) Java downcasts automatically, but you must explicitly upcast c) Java expects the user to explicitly upcast and downcast d) Java will both upcast and downcast automatically e) The rules for upcasting and downcasting depend upon whether classes are declared public, protected, or private

a) Java upcasts automatically, but you must explicitly downcast

What kind of performance can you expect if you perform linear search on a sorted array? a) The performance will be about the same as on an unsorted array b) The performance will be much better than on an unsorted array c) The performance will be much worse than on an unsorted array d) The performance will be worse than n2 in this case e) none of the above

a) The performance will be about the same as on an unsorted array

What are the main programming mechanisms that constitute object-oriented programming? a) encapsulation, inheritance, polymorphism b) encapsulation, abstraction, inheritance c) inheritance, polymorphism, recursion d) polymorphism, recursion, abstraction e) none of the above

a) encapsulation, inheritance, polymorphism

We compare sorting algorithms by examining: a) the number of instructions executed by the sorting algorithm b) the number of instructions in the algorithm itself (its length) c) the types of loops used in the sorting algorithm d) the amount of memory space required by the algorithm e) whether the resulting array is completely sorted or only partially sorted

a) the number of instructions executed by the sorting algorithm

Which of the following statements is completely true? a) If a class is declared to be abstract then every method in the class is abstract and must be overridden b) If a class is declared to be abstract then some methods in the class may have their bodies omitted c) If a class is declared to be abstract then all methods in the class must have their bodies omitted d) If a class is declared to be abstract then all the instance variables must be overridden when a concrete class is derived from the abstract base class

b) If a class is declared to be abstract then some methods in the class may have their bodies omitted

Polymorphism is achieved by: a) overloading b) overriding c) embedding d) abstraction e) encapsulation

b) overriding

Comparing the performance of selection sort and insertion sort, what can one say? a) Selection sort is more efficient than insertion sort b) Insertion sort is more efficient than selection sort c) The efficiencies of both sorts are about the same d) The efficiencies of both sorts depend upon the data being sorted e) none of the above

c) The efficiencies of both sorts are about the same

What is the efficiency of binary search? a) n2 b) n c) log2 n d) n/2 e) none of the above

c) log2 n

Comparing the amount of memory required by selection sort and insertion sort, what can one say? a) Selection sort requires more additional memory than insertion sort b) Insertion sort requires more additional memory than selection sort c) Both methods require about as much additional memory as the data they are sorting d) Neither method requires additional memory e) one of the above

d) Neither method requires additional memory


Kaugnay na mga set ng pag-aaral

physics lab pre and post quizzes

View Set

bold words from compact guide to the whole bible

View Set

Algebra: Equations & Expressions Practice

View Set

Activity 2.1.1 Building a Medical History

View Set

Chapter 11 - Physical and cognitive development in adolescence

View Set

NCLEX CHAPTER 40 - Cardiovascular Disorders

View Set

Ch. 4 Agency and it's Responsibilities

View Set