# Register now to access 7 million high quality study materials (What's Course Hero?) Course Hero is the premier provider of high quality online educational resources. With millions of study documents, online tutors, digital flashcards and free courseware, Course Hero is helping students learn more efficiently and effectively. Whether you're interested in exploring new subjects or mastering key topics for your next exam, Course Hero has the tools you need to achieve your goals.

6 Pages

### Test03-2003-03

Course: CS 101, Fall 2008
School: UVA
Rating:

Word Count: 930

#### Document Preview

____________________________________ PLEDGED NAME CS 101 TEST 3 EMAIL ID_______________________ 1. What is your course section? Answer: ____________ Questions 2 8 consider the following class C. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. public class C { private Point p; // instance variable public C(Point v) { // specific constructor p = new...

Register Now

#### Unformatted Document Excerpt

Coursehero >> Virginia >> UVA >> CS 101

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
____________________________________ PLEDGED NAME CS 101 TEST 3 EMAIL ID_______________________ 1. What is your course section? Answer: ____________ Questions 2 8 consider the following class C. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. public class C { private Point p; // instance variable public C(Point v) { // specific constructor p = new Point(v.getX(), v.getY()); } public void set(Point v) { p = v; } public void perform(Point v) { v.setX(10); p.setX(10); } public void do(Point v) { v = new Point(10, 0); p = v; } public static int f(int x) { return x + 7; } // instance method // instance method // instance method // class method public static void g(int x) { // class method System.out.println( x + 7 ); } } 2. Consider the following code segment. 1. 2. Point origin = new Point(0, 0); C item = new C(origin); C item p Point: (0, 0) After it completes, memory has the following depiction. origin Point: (0, 0) Do item's instance variable p (i.e., item.p) and origin refer to the same Point object after the preceding code segment? YES ______ NO _____ CS 101 PAGE 1 OF 6 PLEDGED NAME ____________________________________ PLEDGED CS 101 TEST 3 EMAIL ID_______________________ 3. Consider the same code segment. Do item.p and origin refer to equivalent Point objects after the code segment finishes? 1. 2. Point origin = new Point(0, 0); C item = new C(origin); YES ______ NO _____ 4. Consider the following code segment. Do item.p and origin refer to the same Point object after the code segment finishes? 1. 2. 3. Point origin = new Point(0, 0); C item = new C(origin); item.set(origin); YES ______ NO _____ 5. Consider the following code segment. Do item.p and origin refer to the same Point object after the code segment finishes? 1. 2. 3. Point origin = new Point(0, 0); C item = new C(origin); item.perform(origin); YES ______ NO _____ 6. Consider the following code segment. Do item.p and origin refer to the same Point object after the code segment finishes? 1. 2. 3. Point origin = new Point(0, 0); C item = new C(origin); item.do(origin); YES ______ NO _____ 7. Consider the following code segment. Does it compile successfully? 1. int y = C.f(4); YES ______ NO _____ 8. Consider the following code segment. Does it compile successfully? 1. int y = C.g(4); YES ______ NO _____ 9. Suppose b is an already defined and initialized int array with 5 elements. Write a single statement that defines and initializes an int variable i to the value of the first element in b. 10. Suppose b is an already defined and initialized int array with 5 elements. Write a single statement that defines and initializes an int variable i to the value of the last element in b. CS 101 PAGE 2 OF 6 PLEDGED NAME ____________________________________ PLEDGED CS 101 TEST 3 EMAIL ID_______________________ 11. If it is possible, write a static void method swap() that takes two formal int parameters x and y. When invoked, the method is to interchange the values of its actual parameters. For example, with this method the following code segment 1. 2. 3. 4. int a = 10; int b = 11; swap(a, b); System.out.println(a + " 11 10 " + b); should display If it is not possible write to the method explain why? 12. If it is possible write a static void method swap() that takes three formal parameters: an int array a and two int variables i and j. When invoked, the method is to interchange the values of the ith and jth elements of the actual array parameter. For example, with this method the following code segment 1. 2. 3. 4. 5. 6. 7. int[] list = new list[3]; int m = 1; int n = 2; a[m] = 10; a[n] = 11; swap(list, m, n); System.out.println(list[m] + " 11 10 " + list[n]); should display If it is not possible to write the method explain why? CS 101 PAGE 3 OF 6 PLEDGED NAME ____________________________________ PLEDGED CS 101 TEST 3 EMAIL ID_______________________ Questions 13 16 have you complete and use the following class State, where class State provides a representation of two values interest in regard to a state -- its name and population size. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. public class State { private String name; private int size; // represents name of the state // represents number of people in the state public State() { // TO BE FILLED IN ************** } public State(String s, int n) { name = s; size = n; } public String toString() { return "(" + name + ": " + size + ")"); p = v; } public Object clone() { // TO BE FILLED IN ************** return result; } public boolean equals(Object v) { // TO BE FILLED IN ************** } } 13. Write a single statement that can replace line 6 so that the default constructor initializes a State object to represent Virginia with its population of 7,078,515 people. 14. Write a single statement that can replace line 20 so that the clone() method produces a new object that is equivalent to the invoking (this) object. CS 101 PAGE 4 OF 6 PLEDGED NAME ____________________________________ PLEDGED CS 101 TEST 3 EMAIL ID__________________...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

UVA - CS - 101
UsingObjectsCS101E AaronBloomfieldAnnouncements Midterm1isaweekfromthisWednesday TESTSAREINCHM402! Schedule:Thisweek:chapter3 NextMonday:reviewformidtermBringinquestions!HomeworkdoneviaCodeLabUsecodeVIRGIN75921043Thereisalabdu
UVA - CS - 101
GUI programmingGraphical user interfacebased programming Chapter G1 (pages 289314) 1WindchillWindchill There are several formulas for calculating the windchill temperature twcThe one provided by U.S. National Weather Service and is appl
UVA - CS - 101
CS 101 / 101-EAaron Bloomfield Chapter 1: Hardware1What is a computer? Not a rhetorical question! &quot;A device that computes, especially a programmable electronic machine that performs high-speed mathematical or logical operations or that assembl
UVA - CS - 101
ReviewforMidterm31Chapter6:Iteration whileloopsyntax Whilestatements: while(expression)action Actionisexecutedrepeatedlywhileexpressionistrue Once expression is false, program execution movesontonextstatement Actioncanbeasinglestatemento
UVA - CS - 101
Review for exam 1CS 101E Aaron Bloomfield1AnnouncementsExam this Wed In CHM 402 (NOT in Clark G004) Openbook Sample text on websiteAlthough it's doubtful that the book will help muchLab quiz this week Next HW assigned today, d
UVA - CS - 101
Programming with methods and classes 1MethodsInstance (or member) method Operates on a object (i.e., and instance of the class)String s = new String(&quot;Help every cow reach its &quot; + &quot;potential!&quot;); int n = s.length(); Instance method
UVA - CS - 101
IterationJavalooping Options while dowhile for AllowprogramstocontrolhowmanytimesastatementlistisexecutedAveraging Problem Extractalistofpositivenumbersfromstandardinputandproduce theiraverage Numbersareoneperline Anegativenumberactsasa
UVA - CS - 101
CS101E:IntroductionAaronBloomfield MEC205 MEC215 ClarkG004(really) 1AssumptionsThefollowingisassumedforstudentsin101E Youhavetakenacourseequivalentinprogramming Thus,youknowthebasicsofprogramming Youdidnotgeta4ora5ontheAPcomputerscienceexam
UVA - CS - 101
Iteration 1Java loopingOptions while dowhile for Allow programs to control how many times a statement list is executed 2AveragingProblem Extract a list of positive numbers from standard input and produce their average Number
UVA - CS - 101
ClassesCS 101E Chapter 4 Aaron Bloomfield 1Announcements HWs are being renumbered J1, J2, etc., for Java programming assignments C1, C2, etc., for CodeLab assignments HW1 = J1, HW2 = C1, HW3 = C2, etc. HWs J2 and J3 assigned this
UVA - CS - 101
JavabasicsChapter2 CS101E1DisplayForecast.java/Authors:J.P.CohoonandJ.W.Davidson /Purpose:displayaquotationinaconsolewindow publicclassDisplayForecast{Threecomments/methodmain():applicationentrypoint publicstaticvoidmain(String[]args){ Sy
UVA - CS - 101
Even even more on being classyAaron Bloomfield CS 101-E Chapter 4+1Consider this sequence of events.2What happened? Javadidn't &quot;repaint&quot; the rectangles when necessary Javaonly painted the rectangle once Youcan tell Java to repaint i
UVA - CS - 101
ReviewofHWJ3AaronBloomfield CS101EStrandrepresentationStrand nucleotideSequence= String text=tgccagt tgccagt length=7publicStrandslice(inti1,inti2) publicStrand() publicStrand() +length():int publicStrand(Strings) publicStrand(Strings) +charAt
UVA - CS - 101
Visibilities and Static-nessAaron Bloomfield CS 101-EOur Circle classWe are going to write a Circle class Somebody else is going to use it public class Circle { double radius; double Pi = 3.1415926536; }Note the fields are not static Note the ra
UVA - CS - 101
221nosotros weesperamos hopeque that/whatpuede canuna aoracin sentenceleo logleno logzorro foxrpido quickmarrn brownsalt jumpedsalto jumpedsobre overregistro data-logperezoso lazyo orsusyourprofesores professorsestudiantestudent
UVA - CS - 101
A B CD E FThis file has 42 characters.
UVA - CS - 101
/ Authors: J. P. Cohoon and J. W. Davidson/ Purpose: display a quotation in a console windowpublic class DisplayForecast {/ method main(): application entry pointpublic static void main(String[] args) {System.out.print(&quot;I think ther
UVA - CS - 101
CS 101 / CS 101-EFall 2005 http:/www.cs.virginia.edu/~cs101M/W 2:00-3:15 CHM 402 / OLS 009Instructors: CS 101 Aaron Bloomfield http:/www.cs.virginia.edu/~asbCS 101-E David Luebke http:/www.cs.virginia.edu/~luebkeOffice: Olsson Hall, room 228D
UVA - CS - 101
CS 101 / CS 101-EFall 2006 http:/www.cs.virginia.edu/~cs101 CS 101: M/W 2:00-3:15 in CHM 402 CS 101-E: M/W 3:30-4:45 in MEC 341Instructors: CS 101 Aaron Bloomfield http:/www.cs.virginia.edu/~asb Office: Olsson Hall, room 228D Office hours are poste
UVA - CS - 202
CS 202, Discrete Math Spring 2007Mondays and Wednesdays 1:00-1:50 Recitation on Fridays at 11:00 or 1:00Instructor: Aaron Bloomfield. Office: Olsson Hall, room 228D ( Course web page: http:/www.cs.virginia.edu/~cs202/ Introduction: This class will
UVA - CS - 494
CS 494 Homework 3: Due 27 March 2006In this homework, you will complete the second elaboration iteration for the project you described in the first homework. In particular, you will have another functioning version of your system ready by the end o
UVA - CS - 202
CS/APMA 202, Spring 2005Tu/Th 3:30-4:45 Olsson Hall room 120Instructor: Aaron Bloomfield. Office: Olsson Hall, room 228D ( Course web page: http:/www.cs.virginia.edu/~asb/cs202/ Introduction: This class will probably be different than any other mat
UVA - CS - 445
CS 445: Computer GraphicsFall 2006 http:/www.cs.virginia.edu/~cs445 Instructor Aaron Bloomfield http:/www.cs.virginia.edu/~asb Office: Olsson Hall, room 228D Office hours are posted on the website Teaching Assistant Jason Mars http:/www.cs.virginia.
UVA - CS - 415
Wed 02 Nov 2005 02:01:06 AM ESTmodpow.htmlPage 1&lt;!DOCTYPE html PUBLIC &quot;-/W3C/DTD XHTML 1.0 Transitional/EN&quot; &quot;http:/www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt; &lt;html xmlns=&quot;http:/www.w3.org/1999/xhtml&quot; lang=&quot;en-US&quot; xml:lang= &quot;en-US&quot;&gt; &lt;hea
UVA - CS - 415
CS 415: Programming Languages Homework 2: Ocaml Due Friday, 23 September by 10 a.m.For this homework, you will need to write three Ocaml functions that deal with DFAs and NFAs: dfasimulate: given a DFA and input, will return the state transition of
UVA - CS - 415
CS 415: Programming Languages Homework 1: Fortran Due Friday, 9 September by 10 a.m.For this homework, you will need to write a Fortran program that will compute whether a circle and a triangle intersect. The program will get (as user input) the loc
UVA - CS - 494
CS 494 Homework 5: Due 2 May 2006In this homework, you will complete the fourth (and last!) elaboration iteration for the project you described in the first homework. In particular, you will have the completed version of your project ready by the e
UVA - CS - 494
CS 494 Homework 1: Due 13 Feb 2006For this homework, you will generate a proposal for a project that you will be working on throughout the semester. Essentially, you will be going through the inception phase for your project. You can work in groups
UVA - CS - 494
CS 494: Object Oriented DesignSpring 2006 http:/www.cs.virginia.edu/~cs494M/W/F 12:00-12:50 MEC 339Instructor: Aaron Bloomfield http:/www.cs.virginia.edu/~asb Office: Olsson Hall, room 228D Office hours are posted on the website Other course pers
UVA - CS - 101
CS 101 Fall 2005 Final ExamName: _Email ID: _This exam is open text book but closed-notes, closed-calculator, closed-neighbor, etc. Unlike midterm exams, you have a full 3 hours to work on this exam. This final exam is optional; you may choose
UVA - CS - 494
CS 494 Homework 2: Due 27 Feb 2006In this homework, you will complete the first elaboration iteration for the project you described in the first homework. In particular, you will have a fully functioning prototype version of your system ready by th
UVA - CS - 202
CS/APMA 202Midterm 27 April 2005Name: _E-mail ID: _@virginia.eduPledge: _ __ _ Signature: _There are 75 minutes for this exam and 100 points on the test; don't spend too long on any one question! The 12 short answer questions require only
UVA - CS - 101
CS 101 Fall 2005 Midterm 1Name: _Email ID: _This exam is open text book but closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts (in particular, the final question is worth substantially more than any oth
UVA - CS - 101
CS101 Fall 2005 Midterm 2 Grading GuidelinesQuestion 3: 4 points, each answer worth 1 point Question 4: 3 points, there should be 3 numbers output, each worth a point. Question 5: 3 points, one for each value (j,k, flag) Question 6: 5 points a. 3 va
UVA - CS - 101
CS 101 Spring 2006 Midterm 2Name: _Email ID: _This exam is open text book but closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sure to look over all the questions and plan your time accordingly
UVA - CS - 101
Pledged CS 101 Exam 3 Spring 2005Email Id _ Name _This pledged exam is open text book and closed notes. Different questions have different points associated with them. Because your goal is to maximize your number of points, we recommend that you
UVA - CS - 101
CS 101 Final Exam Fall 2005Email Id _Name _This pledged exam is open text book and closed notes. Different questions have different points associated with them. Because your goal is to maximize your number of points, we recommend that you do not
UVA - CS - 415
CS 415 Midterm Exam Spring 2002Name _KEY _ Email Address _ Student ID # _Pledge:This exam is closed note, closed book. Good Luck!Score Fortran Algol 60 Compilation Names, Bindings, Scope Functional Programming Total/100CS415Anderson Sp
UVA - CS - 415
INTERCALAaron Bloomfield CS 415 Fall 2005A note about the sourcesThe main sources for this lecture set are:The INTERCAL page in Wikipediahttp:/en.wikipedia.org/wiki/IntercalThe INTERCAL Programming Language Revised Reference Manual
UVA - CS - 445
TransformationsAaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Luebke)Graphics coordinate systems X is red Y is green Z is blue2Graphics coordinate systemsIf you are on the +z axis, and +y is
UVA - CS - 415
Names, Scopes and BindingsAaron Bloomfield CS 415 Fall 200511Binding A binding is an association between two things, such as a name and the thing it represents Example: int x When this statement is compiled, x is bound to a memory space2B
UVA - CS - 415
Debuggers, Analysis Tools and ProfilersAaron Bloomfield CS 415 Fall 20051What is a Debugger?&quot;A software tool that is used to detect the source of program or script errors, by performing step-by-step execution of application code and viewing the
UVA - CS - 445
Rendering PipelineAaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by Greg Humphreys)3D Polygon RenderingMany applications use rendering of 3D polygons with direct illumination23D Polygon RenderingMany ap
UVA - CS - 445
LightingAaron Bloomfield CS 445: Introduction to Graphics Fall 2006Lighting Sogiven a 3-D triangle and a 3-D viewpoint, we can set the right pixels But what color should those pixels be? If were attempting to create a realistic image, we need
UVA - CS - 415
ScanningAaron Bloomfield CS 415 Fall 20051Parsing &amp; Scanning In real compilers the recognizer is split into two phases Scanner: translate input characters to tokens Also, report lexical errors like illegal characters and illegal symbols Pars
UVA - CS - 445
Rendering Pipeline and Graphics HardwareAaron Bloomfield CS 445: Introduction to Graphics Fall 2006Overview Framebuffers How is the rasterized Rendering Pipeline scene kept in memory? Transformations Lighting Clipping Modeling Camera Vis
UVA - CS - 202
Set OperationsCS/APMA 202, Spring 2005 Rosen, section 1.7 Aaron Bloomfield1Sets of ColorsMonitor gamut (M) Printer gamut (P) Pick any 3 &quot;primary&quot; colors Triangle shows mixable color range (gamut) the set of colors2Set operations: Union 1
UVA - CS - 415
In More Depth.Grammars Parsing(Slides copied liberally from Ruth Anderson, Hal Perkins and others)04/19/09CS415 - Fall 20051Parsing The syntax of most programming languages can be specified by a context-free grammar (CGF) Parsing: Given a
UVA - CS - 202
Nested QuantifiersCS/APMA 202, Spring 2005 Rosen, section 1.4 Aaron Bloomfield1Multiple quantifiersYou can have multiple quantifiers on a statement x y P(x, y) &quot;For all x, there exists a y such that P(x,y)&quot; Example: x y (x+y = 0) xy P(x,y)
UVA - CS - 445
CS 445 Introduction to Computer GraphicsFall 2006 Aaron BloomfieldOverviewIntroductionWhat is computer graphics? What is it good for? What will I learn in this course? How much work will there be?ApplicationsSyllabusCoursework
UVA - CS - 415
CS 415: Programming LanguagesAlgol Aaron Bloomfield Fall 2005Historical perspectiveBy mid/late 50s a lot of PLs were out there Interest in universal language European and American groups got together in Zurich Result was Algol 58 8 people spe
UVA - CS - 445
General-Purpose Computation on Graphics HardwareDavid LuebkeUniversity of VirginiaCourse Introduction The GPU on commodity video cards has evolved into an extremely flexible and powerful processor Programmability Precision Power We are in
UVA - CS - 445
RasterizationAaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Luebke)The Rendering Pipeline: A TourTransform Illuminate Transform Clip Project RasterizeMode &amp; C e l am ra Param te e rsRe ring Pipe nde
UVA - CS - 202
FunctionsCS 202 Epp section ? Aaron Bloomfield1Definition of a function A function takes an element from a set and maps it to a UNIQUE element in another set2Function terminologyf maps R to Z Domain R f Z Co-domainf(4.3) 4.3 4Pre-image
UVA - CS - 202
Propositional EquivalencesCS/APMA 202, Spring 2005 Rosen, section 1.2 Aaron Bloomfield1Tautology and ContradictionA tautology is a statement that is always truep p will always be true(Negation Law)A contradiction is a statement that is al
UVA - CS - 415
Objective Caml (Ocaml)Aaron Bloomfield CS 415 Fall 20051ML history ML first developed in late 1970's Stands for Meta Langauage Not a &quot;pure&quot; function language Has functions with side effects, imperative programming capabilities Haskell is a
UVA - CS - 202
Methods of ProofCS 202 Rosen section 1.5 Aaron Bloomfield1In this slide set.Rules of inference for propositions Rules of inference for quantified statements Ten methods of proof2Proof methods in this slide setLogical equivalences Ten pro
UVA - CS - 202
Boolean LogicCS 202, Spring 2007 Epp, sections 1.1 and 1.2 Aaron Bloomfield1Administratrivia HW 1: due next Friday Section 1.1 # 49, 52 Section 1.2 # 34, 44, 46 Today's lecture will be somewhat of a review Next week we will see applications
UVA - CS - 445
Making MoviesAaron Bloomfield CS 445: Introduction to Graphics Fall 2006 (Slide set originally by David Brogan)Making Movies Concept Storyboarding Sound Character Development Layout and look Effects Animation Lighting2Concept&quot;Not
UVA - CS - 101
GUI programmingGraphical user interfacebased programmingWindchill Windchill There are several formulas for calculating the windchill temperature twc The one provided by U.S. National Weather Service and is applicable for a windspeed greater tha
UVA - CS - 101
Fall 2004 - CS 101: Test 1Name _UVA Email ID _I. Computing and programming fundamentals1. (4 points) Give two examples of non-PC computing devices.Part I Part II Part III2. (4 points) What does Java program compilation do?Total3. (4 poin