10 Pages

Tutorial8_soln

Course: ITEC 1620, Fall 2009
School: Maple Springs
Rating:
 
 
 
 
 

Word Count: 730

Document Preview

Scope, Parameters, References: Sample 1: The file AnInt.java contains the following implementation of the AnInt class: public class AnInt { public int data; } The file TwoInts.java contains the following implementation of the TwoInts class: public class TwoInts { public AnInt obj; public int data; public void update1(AnInt obj) { obj = this.obj; } public void update2(AnInt obj) { this.obj = obj; } public void...

Register Now

Unformatted Document Excerpt

Coursehero >> Maryland >> Maple Springs >> ITEC 1620

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.
Scope, Parameters, References: Sample 1: The file AnInt.java contains the following implementation of the AnInt class: public class AnInt { public int data; } The file TwoInts.java contains the following implementation of the TwoInts class: public class TwoInts { public AnInt obj; public int data; public void update1(AnInt obj) { obj = this.obj; } public void update2(AnInt obj) { this.obj = obj; } public void update3(AnInt obj) { obj.data = data; } public void update4(int data) { obj.data = data; } public void update5(int data) { obj.data = this.data; } public void update6(TwoInts obj) { obj.obj.data = obj.data; } public void update7(TwoInts obj) { obj.data = this.obj.data; } } The main method in the file MainClass.java uses the above classes: import york.*; public class MainClass { private AnInt a; private AnInt b; private TwoInts x; private TwoInts y; private int data; public static void main(String[] args) { MainClass temp = new MainClass (); } public MainClass() { run(); } private void { a = new b = new x = new y = new refresh () AnInt(); AnInt(); TwoInts(); TwoInts(); a.data = 1; b.data = 2; x.obj = a; x.data = 3; y.obj = b; y.data = 4; data = 5; } private void run() { refresh(); x.update1(b); York.println("a"+a.data+b.data+x.obj.data+y.data); refresh(); x.update2(b); York.println("b"+a.data+b.data+x.obj.data+y.data); refresh(); x.update3(b); York.println("c"+a.data+b.data+x.obj.data+y.data); refresh(); x.update4(data); York.println("d"+a.data+b.data+x.obj.data+y.data); refresh(); x.update5(data); York.println("e"+a.data+b.data+x.obj.data+y.data); refresh(); x.update6(y); York.println("f"+a.data+b.data+x.obj.data+y.data); refresh(); x.update7(y); York.println("g"+a.data+b.data+x.obj.data+y.data); } } Please write the program outputs below when java MainClass is executed. obj = this.obj; a1214 local variable obj is updated, nothing else b1224 this.obj = obj; obj is b, this.obj becomes b, x.obj becomes b c1314 obj.data = (this.) data; obj is b, data is instance variable d5254 (this.) obj.data = data; obj is a, data is parameter e3234 (this.) obj.data this.data; = obj is a, this.data is instance variable f1414 obj.obj.data = obj.data; obj is y, obj.obj is b g1211 obj.data = this.obj.data; obj is y, this is x, this.obj is a a) a b data x 5 y AnInt data 1 AnInt data 2 TwoInts update1() obj this obj data 3 TwoInts obj data 4 b) a b data x AnInt data 1 5 y AnInt data 2 TwoInts update2() obj this obj data 3 TwoInts obj data 4 c) a b data x 5 y AnInt data 1 AnInt data 2 3 update3() obj this obj data 3 d) a b data x AnInt data 1 5 AnInt data 2 update4() obj this data 5 TwoInts obj data TwoInts 4 5 y TwoInts obj 3 TwoInts data data 4 e) a b data x 5 y AnInt data 1 3 AnInt data 2 TwoInts update5() obj this data 5 TwoInts obj data 3 data 4 f) a b data x AnInt data 1 5 y AnInt data 2 4 TwoInts update6() obj this obj data 3 TwoInts obj data 4 g) a b data x 5 y AnInt data 1 AnInt data 2 TwoInts update7() obj this obj data 3 TwoInts obj data 4 1 Sample 2: The file AnInt.java contains the following implementation of the AnInt class: public class AnInt { public int data; public void update(IndInt indInt) { indInt.obj.data = data; } } The file IndInt.java contains the following implementation of the IndInt class: public class IndInt { public AnInt obj; public void update(AnInt other) { other.update(this); } } The main method in the file MainClass.java uses the above classes: import york.*; public class MainClass { public static void main(String[] args) { IndInt a = new IndInt(); IndInt b = new IndInt(); AnInt x = new AnInt(); AnInt y = new AnInt(); AnInt z = new AnInt(); x.data = 5; y.data = 7; a.obj = y; b.obj = z; z.data = y.data; y.data = 10; a.obj.data = 3; a.obj = x; York.println(a + a.obj.data + b.obj.data + x.data + y.data + z.data); b.update(a.obj); York.println(b + a.obj.data + b.obj.data + x.data + y.data + z.data); } } Please write the program outputs below when java MainClass is executed. a57537 b55535 a57537 IndInt a b obj IndInt obj AnInt x data 5 AnInt y data 7, 10, 3 AnInt z data 7 5 b55535 b.update(a.obj) b.update(x) x.update(b) b.obj.data = x.data z.data = 5
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:

Maple Springs - ITEC - 1011
Program 2 AS/AK/ITEC 1011 3.0, Section CIn a certain game of chance, a player rolls two six-sided dice. The sum of these two dice can be 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, or 12. A sum of 7 or 11 on the first roll causes the player to win. A sum of 2,
Wash & Jeff - ECN - 303
ECN 303 1.Word Document SampleHW 4Your NameThe Risk Structure of Interest RatesThe following table and chart provide the income interest rates (explain) for four different bond funds with different levels of risk blah blah blah (you must add
Wash & Jeff - ECN - 102
ECN 102Introduction to MacroeconomicsLecture 4Dr. SwintI.The Circular Flow Model of Economic ActivityThe circular flow model is useful for describing a market economy's major sectors & major types of activities (that are going on continuou
UMBC - CHEM - 111
How Gases Differ from Solids and Liquids1. gas volume changes significantly with pressure 2. gas volume changes significantly with temperature 3. gases have relatively low viscosity (resistance to flow) 4. most gases have relatively low densities(~
Maple Springs - MATH - 1131
Example:250 York undergraduate students are randomly selected. The following data are recorded.Note: 0 = first year student 1 = second year student 2 = third year student 3 = fourth year student 4 = spent more than 4 yea
UMBC - CHEM - 111
Chem Activity 23 Quantum Wave Model of the Atom Description of Electrons in AtomsChem 111 Dr.C DoigeModel 1. Energies of Orbitals in Multielectron Atoms vs the Hydrogen AtomOne of the reasons that Bohr was successful in calculating the energi
Maple Springs - ITEC - 1011
Program 2 AS/AK/ITEC 1011 3.0, Section RTo decide who gets to sit in the front seat of their mothers car, Billy and Sandy are going to play paper, scissors, rock (PSR). They will play PSR, best two out of three (and they will not play the third if
Maple Springs - ITEC - 1011
Program 1 AS/AK/ITEC 1011 3.0, Section CThe Fibonacci number series is as follows:0, 1, 1, 2, 3, 5, 8, 13, 21, 44, It begins with 0 (the zeroth Fibonacci number) and 1 (the first Fibonacci number) and has the property that each subsequent Fibona
UMBC - CHEM - 111
Chem Activity 10 Balanced Chemical Reaction EquationsChem 111 Dr.C Doige Adapted from HansonModel 1: Alcohol Burns Blue A One-Act Play in Two Scenes(Have fun acting this play out in class! See if you can extract the key ideas about balancing r
UMBC - CHEM - 111
Chem Activity 3 Atoms, Ions and IsotopesChem 111 Dr.C Doige Adapted from Moog and FarrellModel 1: Diagrams for various atoms, ions and isotopesThe above diagrams represent atoms and ions of hydrogen and carbon. The nucleus of an atom contains
UMBC - CHEM - 111
Dr. C Doige Chem 111/112Response to article: Blake, B. (2003) Solubility Rules: Three Suggestions for Improved Understanding. J. Chem. Educ., 80 (11), 1348-1350.Prior Understanding and/or Experience with the Topic Prior to reading this article I
UMBC - CHEM - 111
Chem Activity 4 Atoms, Ions and IsotopesChem 111 Dr.C Doige Adapted from Moog and FarrellModel 1: Diagrams for various atoms, ions and isotopesThe above diagrams represent atoms and ions of hydrogen and carbon. The nucleus of an atom contains
UMBC - CHEM - 111
Chem Activity 9 Chemical Formulas and NomenclatureChem 111 Dr.C DoigeModel 1: Periodic Table and charges of common monoatomic ionsNaCl MgCl2 AlCl3 K3NExamples of Binary Ionic Compounds iron (II) bromide sodium chloride FeBr2 FeBr3 iron (III)
UMBC - CHEM - 111
Chem 111 Dr. C. Doige Chem Activity 10 Stoichiometry in Chemical Reactions Key Questions Model 1: Calculating the mass of product formed from a given amount of reactant 1. One area of concern to an industrial chemist is how to extract a metal elemen
UMBC - CHEM - 111
Chem 111 Dr. C Doige Adapted from Nigel Eggers (UBCO) Problem Set IV Stoichiometry 1. Balance the following equations: N2O5(g) + H2O(l) HNO3(aq) Mg2C3(s) + H2O(l) Mg(OH)2(s) + C3H4(g) PCl5(l) + H2O(l) H3PO4(aq) + HCl(aq) 2. Balance the following
UMBC - CHEM - 111
Chem 111 Dr. C Doige Quiz 2b- September 22, 2006 Black holes are where God divided by zero. Steven Wright Name _ Student Number_Show all of your work for full marks, and watch sig figs and units. There are two naturally occurring isotopes of silve
Maple Springs - ELIC - 629
Lab 6Image ProcessingFiltering of ImagesELIC629Objectives:! ! ! ! To perform image blurring operations. To use MATLAB to perform one-dimensional filtering of an image. To investigate several kinds of image filters. To investigate image scalin
UMBC - CHEM - 111
Chemistry 111 Part 1: Answer All Questions (70 marks total)1.Final Examination 2005Complete the following table. Z 14 34 A 28 79 # protons 14 34 # neutrons 14 45 #electrons 10 36 Q 4+ 2A Q ZE[2] nuclide symbol28 4+ 14 Si 79 2- 34 SeElement
UMBC - CHEM - 111
UMBC - CHEM - 111
UMBC - CHEM - 111
Chem 111 Dr.C Doige Adapted from Moog and FarrellChem Activity 3 Atoms, Ions and Isotopes Model: Diagrams for various atoms, ions and isotopes3. How many electrons are found in 12C?13C?12C- ?4.a) What feature distinguishes a neutral
Maple Springs - ELIC - 629
Lab 5Image ProcessingUsing IMAQ Vision Morphology FunctionsELIC629Objectives:! ! ! ! ! To apply a threshold and various morphology techniques in IMAQ Vision Builder. To apply particle analysis techniques in IMAQ Vision Builder and use IMAQ Vi
UMBC - CHEM - 111
Introduction Chem 111 - Lesson 1Myths and Truths to Success in General ChemistryChem 112 - Dr. C Doige1Introduction Chem 111 - Lesson 1A correlation exists between grades and where you sit in the classroom Making your Mark, Lisa Fraser 100 G
Maple Springs - ELIC - 629
Lab 7Image ProcessingEdge Detection and ApplicationsELIC629Objectives:! ! ! ! ! To perform edge detection operations. To use the caliper function for gauging jumper switches without any programming. To measure circularity. To measure the dist
UMBC - CHEM - 111
Chem Activity 10 Stoichiometry in Chemical Reactions Problems 1.Chem 111 Dr.C DoigeThe solid fuel in the booster stage of the space shuttle is a mixture of ammonium perchlorate and aluminium powder, which react as follows: NH4ClO4 (s) + Al (s)
Maple Springs - ELIC - 629
Lab 2Image ProcessingELIC629Acquiring and Displaying Images Using LabVIEW and IMAQObjectives:! ! ! ! ! To acquire live images programmatically using LabVIEW. To acquire live images using a WHILE loop around IMAQ Snap.vi. To acquire live imag
Maple Springs - ELIC - 629
Lab 8Image Processing Pattern Matching Using IMAQ VisionELIC629Objectives:! ! To program a machine vision application that can snap an image and perform a useful measurement. To select a region of interest in an image and apply pattern matchin
East Los Angeles College - ACB - 201
Journal of Thermal Biology 27 (2002) 429432Water temperature and internesting intervals for loggerhead (Caretta caretta) and green (Chelonia mydas) sea turtlesG.C. Haysa,*, A.C. Brodericka, F. Glena, B.J. Godleya, J.D.R. Houghtona, J.D. Metcalfeb
Berkeley - MCB - 200
MCB 200 - Fall, 2007 - Prof. Jeremy ThornerDISCUSSION SESSION ON LECTURE #5:STUDY QUESTIONSASSIGNED PAPERS: Cherezov V et al. (2007) High-resolution crystal structure of an engineered human 2-adrenergic G protein-coupled receptor. Science 318:
Maple Springs - CSE - 3301
East Los Angeles College - FM - 234
Biol. Lett. doi:10.1098/rsbl.2005.0357 Published onlineBenets of organic farming to biodiversity vary among taxaR. J. Fuller1,*, L. R. Norton2, R. E. Feber3, P. J. Johnson3, D. E. Chamberlain1, A. C. Joys1, F. Mathews3, R. C. Stuart2, M. C. Townse
Maple Springs - CSE - 1019
For each of the following recurrences, use the Master Theorem to give an asymptotic bound on each of the dened sequences. (I.e., give a function f (n) such that T (n) is (f (n).) 1. T (0) = T (1) = T (n) = 2. T (0) = T (1) = T (n) = 3. T (1) = T (n)
Maple Springs - CSE - 1020
1 1 (5 marks)Draw the ow of control diagram corresponding to the following fragment. statement-S; for (initial; condition; bottom) { body; } statement-X; See Figure ? on page ? of the textbook.2 (6 marks)Recall that the methods p
Maple Springs - CSE - 3401
2001 July 163401 Lisp Programming ExercisesPage 1 of 5Lisp Recursive Programming Exercises1. Write a Lisp macro mycase that translates the following macro call. Assume the input will be error free. The input lists can be any length. You must d
UMBC - STAT - 121
Maple Springs - CSE - 3401
March 4, 2004 COSC 3401, Winter 2004 Assignment #3 Due: For this report: 1. I want you to electronically submit TWO files that contain all your functions/predicates. The first file will have your code for question #1, the second file will have the co
Maple Springs - CSE - 3401
2007 January 143401 Example Lisp Test QuestionsPage 1 of 6Example Test Questions for LispTest questions can be based on the following sources: (1) the textbook(s), (2) readings, (3) lectures, (4) reports, (5) exercises, and (6) on-line notes a
UMBC - MATH - 221
Linear EquationsA linear equation in n variables xi , i = 1, . . . , n, is of the formwhere , are constant coefcients and b is a constant, all assumed to be real numbers. Another way to say this is that a linear equation contains no powers of the
UMBC - MATH - 111
Okanagan College Math 111 (71) Fall 2008 Term Test Two MarksheetInstructor: Clint Lee Thursday October 30Student Name:Total Marks: 40Problem1 (a) 1 (b)Marks/3 /21 Total2 (a) 2 (b) 2 (c) /3 /3 /2/52 Total3 (a) 3 (b) 3 (c) /2 /4 /2
UMBC - MATH - 221
Systems of Linear EquationsSolving Linear SystemsLecture 1: Solving Systems of Linear EquationsSystems of Linear Equations Linear Equations Linear Systems The Solution(s) to a Linear SystemSolving Linear Systems The Augmented Matrix Elementar
UMBC - MATH - 112
Math 112 (71) Fall 2008Example 1 The graph of a function f is shown. In parts (a) to (e) compute the limit if it exists. If the limit does not exist, determine if the limit is an innite limit, and, if it is, state whether it is + or . Otherwise, exp
UMBC - MATH - 112
Limits at Innity Limits at Innity for Polynomials Limits at Innity for the Exponential Function Function Dominance More on AsymptotesLecture 5 Limits at Innity and AsymptotesLimits at Innity Horizontal Asymptotes Limits at Innity for Polynomials
UMBC - MATH - 112
Slope of the Tangent LineMore about the Slope of the Tangent LineThe Binomial FormulaLecture 6: Slope of the Tangent LineSlope of the Tangent Line Estimating with a Secant Line A Limit Giving the Slope of the Tangent Line The Denition of the
Maple Springs - CSE - 6412
Mining Association Rules with ConstraintsWei Ning Joon Wong COSC 6412 Presentation1Outline Introduction Summary of Approach Algorithm CAP Performance Analysis Conclusion References2Outline IntroductionSummary of Approach Algor
UMBC - MATH - 112
Evaluating LimitsLimits can be evaluated numerically using Limit Laws to reduce the limit to a known limit algebraically using the Squeeze Theorem We will cover the rst two of these approaches in this lecture and other two in the next lecture.Clin
UMBC - MATH - 122
Math 122 (71) Fall 2005 Assignment Three Problems & SolutionsDue: Monday December 12Instructions. Do all parts of all 7 questions. Show all signicant steps in your work. You will not receive any marks for just an answer, even if it is correct. Us
East Los Angeles College - JEHD - 201
Testing for Fractional Cointegration: the Relationship between Government Popularity and Economic Performance in the UKJames Davidson Cardi University This version: March 2003Abstract This paper investigates the relationship between the quarterly
East Los Angeles College - SC - 204
AuctionsFCC auctions of radio frequencies in 1994 3 G auctions in UK Paintings-Christies and Sotheby Auction type 1. EnglishFirst price open cry2. First price sealed bid 3. Second price sealed bid 4. DutchAuctions with perfect informationWe i
South Carolina Aiken - APLS - 110
MODULE IXPage 1 MODULE IX: PUBLIC POLICYAPLS 110My policy is to have no policy. Abraham Lincoln OUTLINE I. Public Policy: Definition II. General Steps in the Policy Process and Problems in Each Step A. Goal selection-Demands B. Choosing among a
Maple Springs - CSE - 4301
COSC4301 Midterm Sample QuestionsQuestion 1 Suppose you wanted to declare a data structure to represent information about a computer vendor's inventory's items, which includes information about keyboards, monitors and hard disk drives. Show how you
UMBC - MATH - 221
Okanagan College Math 221 (071) Winter 2009 Problem Set 1 SolutionsInstructor: Clint Lee Selected Problems due Tuesday Jan 20 1. (1.1, Problem 10) The system has already been reduced to triangular form (echelon form). First replace R2 by R2 + (4) R
UMBC - MATH - 221
Okanagan College Math 221 (071) Winter 2009 Problem Set 4a SolutionsInstructor: Clint Lee Selected Problems covered on Term Test One 1. (2.1, Problem 4) 9 A 5I3 = 8 4 and 4 1 3 1 0 0 1 3 2 6 7 6 5 0 1 0 = 8 4 1 3 0 0 1 1 8 5 15 35 3
Maple Springs - ASG - 3402
% -% CSE 3402 Assignment 1% Family name:% Given name:% Student number:% Answers to Questions 6-10% Instructions: % Please edit this file in the following way to answer the text% questions of Assignment 1. % - Please replace any
Berkeley - MCB - 141
MCB 141, 24-25 February 2009 GSI: Jess Lyons Name_ 1. (A) What question were the authors trying to address? Are the DNA sequence changes between the eve stripe 2 enhancers of the two species of any functional consequence? 2. (B) What did they already
Maple Springs - COSC - 1530
Introduction to Computer Use IIOverview (1):Before We BeginSome administrative details Some questions to considerManipulation of Strings (Cont.)Example Exercise 5-4Winter 2006 (Section M)Topic D: Control Structures - IterationWednesday, Ma
Berkeley - MCB - 141
MCB 141, 25-26 February 2009 EVE STRIPE 2 EVOLUTION PAPER WORKSHEET Name_ 1. What question were the authors trying to address? Are the DNA sequence changes between the eve stripe 2 enhancers of the two species of any functional consequence? 2. What a
Maple Springs - CSE - 1020
Introduction to Computer Science IOverview (1):Before We BeginSome administrative details Some questions to considerThe Class ObjectWhat is the Object class ?File Input/OutputThursday, July 20 2006File Input and OutputOverview Introducti
Maple Springs - COSC - 1530
Introduction to Computer Use IIOverview (1):Before We BeginSome administrative details Some questions to considerObject Oriented Programming (cont.)Fundamental concepts Shape ExampleWinter 2005 (Section M)Topic A: Introduction to Problem So
Maple Springs - CSE - 3301
Chapter 2 : Programming Language SyntaxProgramming Language PragmaticsMichael L. ScottCopyright 2005 ElsevierReview What is a programming language ? Why are there so many programming languages ? List several of the factors that make progr
Maple Springs - ELIC - 629
Introduction to Digital Image ProcessingWinter 2005 Image Enhancement in the Spatial Domain:Mid-Term Exam ReviewBill KapralosTuesday, February 14 2006ELIC 629, Winter 2006, Bill KapralosOverview (1):Material You are Responsible ForSections
Johns Hopkins - V - 049
Help-Seeking for Stressful Events Among Chinese College Students in Taiwan: Roles of Gender, Prior History of Counseling, and Help-Seeking AttitudesHsiaowen Chang The present study examined the help-seeking behavior that Chinese college students use