CSE 205 Quiz 7

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

The finally block of a try/catch structure will execute if an exception occurs in the try block.

True

The finally block of a try/catch structure will execute if no exception occurs in the try block.

True

How many arguments does the scratch method take? Refer to the following UML Class Diagram when answering this question. Pet - name : int + age : String + hasFleas : Boolean - licenseNumber : String + weight : float - color : String ---------------------------------------- - Pet() + Pet(name : String, age : int) + getName() : String + setName(name : String) : void - getAge() : int - setAge(age : int) : void + speak() : void + scratch(itches : int, times : int) : void + toString() : String

2

Evaluate the following code to determine the output. MyQueue<Integer> q = new MyQueue<Integer>(); q.add(13); q.add(55); q.add(88); q.remove(); System.out.println(q.remove());

55

Evaluate the following code to determine the output. MyStack<Integer> s = new MyStack<Integer>();s.push(29); s.push(68); s.push(84); s.pop(); System.out.println(s.pop());

68

How many public members does this class have (not including constructors)? Refer to the following UML Class Diagram when answering this question. Pet - name : int - age : String - hasFleas : Boolean + licenseNumber : String + weight : float ---------------------------------- + Pet() + Pet(name : String, age : int) + getName() : String - setName(name : String) : void + getAge() : int + setAge(age : int) : void + speak() : void - scratch(itches : int) : void + toString() : String

7

Which of the following would have a quadratic Big O run-time complexity? a) none of these b) Bubble Sort an unsorted array c) Insert a value into an ArrayList d) Efficiently find the phone number in a phone book, given a person's name e )Determine if a binary number is even or odd

Bubble Sort an unsorted array

Stacks can only be implemented as LinkedLists, while Queues can only be implemented as ArrayLists.

False

Which of the following run-time complexity orders is best? O(log n) Logarithmic time none of these O(2^n) Exponential O(n) Linear time

None of these

A Queue is a First In First Out (FIFO) data structure.

True

Which of the following would have a quadratic Big O run-time complexity? a) Efficiently find the definition of a given word in a dictionary b) Determine if a binary number is even or odd c) none of these d) Find the shortest route to visit n cities by airplane e) Find the largest value in an unsorted list

c) None of these

Which of the following iterative methods is equivalent to this recursive method? int foo(int n) { if (n < 1) return 0; return n + foo(n - 1); }

int foo(int n) { int x = 0; if (n < 1) return 0; while (n > 0) { x += n; n--; } return x; }


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

Exam 1: Health Promotion of Adolescent

View Set

Chapter 7 Creating a Flexible Organization

View Set

n) Chapter 7 Brooker - using chapter 9 Campbell, chapter 8 Mader & others**

View Set