



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A quiz from the university of california, berkeley's department of electrical engineering and computer sciences for the cs61b course. The quiz covers various topics in java programming, including strings, arrays, and recursion. Students are required to fill in the blanks with the correct answers and rate the difficulty and fairness of each question.
Typology: Exams
1 / 6
This page cannot be seen from the preview
Don't miss anything!
Personal Information Last name First Name Student ID Number The name of your TA (please circle) David Igor Ram Rishi Name of the person to your Left Name of the person to your Right All the work is my own. I had no prior knowledge of the exam contents nor will I share the contents with others in CS61B who have not taken it yet. (please sign)
Question Max. Pts
Points Earned
Difficulty (0=easy 5=hard)
Fairness (0=fair 5=unfair)
Write the difficulty and fairness ratings above and please add additional comments fl on the left here.
int j = i; i = 2; System.out.println(j); Ë _____________________
String t = s; s = "two"; System.out.println(t); Ë _____________________
System.out.println (s.substring(1,5).substring(1,3)); Ë _________ System.out.println ("61".concat(s.substring(s.length()-4))); Ë ________
System.out.println(7+8+10); Ë ______________ System.out.println("Realistically: "+6+1+0); Ë Realistically: ________
for (int i=0; i < w1.length(); i++) { if (w1.charAt(i) != w2.charAt(i)) return false; } return true; } // in main String s1 = new String("61B"); String s2 = new String("61B"); System.out.println(s1 == s2); Ë ________ System.out.println(s1.equals(s2)); Ë ________ System.out.println(betterEquals("61B","CS61B")); Ë ________ System.out.println(betterEquals("CS61B","61B")); Ë ________ System.out.println(betterEquals("61B","61B rocks")); Ë ________ System.out.println(betterEquals("61B rocks","61B")); Ë ________
i++; s = "B"; a.deposit(5); a = new Account(88); } // in main int score = 9; String grade = "A"; Account account = new Account(100); // …from Account class on the last page changeValues(score, grade, account); System.out.println(score); Ë ________ System.out.println(grade); Ë ________ System.out.println(account.balance()); Ë ________
public class FixedVector { private Vector myVec; public FixedVector (Vector v) { myVec = v; } public Object get(int i) { return myVec.get(i); } }
public Account (int euro) { this(2 * euro); } // 1 Euro=2$, so 2$ per euro
Enumeration e = v.elements(); for (Integer i = (Integer) e.nextElement() ; e.hasMoreElements() ; i = (Integer) e.nextElement()) System.out.println(i);
public _______________ familyFortune () { // non-static
if ( _______________________________________________ ) { // base case test return ( _______________________________________ ); // base case } else { return ( _______________________________________ ); // recursive case }
}
// Now, show a call to this method using the Account me (from outside Account)
____________________________me______________________________
public static ___________ familyFortuneStatic ( ________________ ) { // static
if ( _______________________________________________ ) { // base case test return ( _______________________________________ ); // base case } else { return ( _______________________________________ ); // recursive case }
}
// Now, show a call to this method using the Account me (from outside Account)
____________________________me_______________________________