Fragments Print - Data Structures - Solved Exams, Exams of Data Structures and Algorithms

Main points of this past exam are: Fragments Print, Potentially Jump, Jump Back, Java’S Continue, Continue Statement, Code Fragment, Fragment Causes, Topmost Bsearch, Singly-Linked List, New Nodes

Typology: Exams

2012/2013

Uploaded on 04/02/2013

shashi_16star
shashi_16star 🇮🇳

4.6

(20)

99 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
pf2

Partial preview of the text

Download Fragments Print - Data Structures - Solved Exams and more Exams Data Structures and Algorithms in PDF only on Docsity!

CS 61B: Midterm I 1 of 2 CS 61B: Data Structures (pring 2005) Midterm I Solutions Problem 1. (4 points) Quickies. a. If you decide later that you want to make a subclass of the class where the instance variable appears, the new functionality that you add to the subclass might need to access the variable. If the variable is protected, you can access it from the subclass. If the variable is private, you'll have no choice but to go back and modify the superclass. (This could be very inconvenient if your company has already released the superclass to customers.) b. circle objects are immutable, because after one has been constructed, it is not possible to change any of its internal state. (The sole field radius is private, and no method of circle modifies it.) c. In a static method, you can never use the keyword this. (You can never use super either.) d. Java's continue statement can only jump back to the beginning of a loop-namely for, while, OF do. Problem 2. (8 points) Inheritance. a. Ml inc b. m2 inc c. Run-time error. (You can't cast an a object to static type c; not every a is ac.) d. Compile-time error. (The interface 8 does not have a whichclass method.) e. (This is the two-point question.) New A New C M1 in C f. mi ina g. Compile-time error. (You cannot create a B object.) Problem 3. (6 points) Binary Search. http://www.cs.berkeley.edu/~jrs/61bs05/exam/05mid1 .html