SWE100 Final Exam Part 1 Vocabulary - 1 pt each Use the following words to fill in the blanks in this section. Note: you can use words more than once, you may need to pluralize the words, and you will...

SWE100 Final Exam Part 1 Vocabulary - 1 pt each Use the following words to fill in the blanks in this section. Note: you can use words more than once, you may need to pluralize the words, and you will not use all of the words Algorithm Assembly language BigInteger Compiler Constant Constructor double Exponent High level language Interpreted Keyword Mantissa Method Naming Convention null Object Parameter Primitive type Reference type Return Type Runnable String Target Machine Typecast


Name: SWE100 Final Exam Part 1 Vocabulary - 1 pt each Use the following words to fill in the blanks in this section. Note: you can use words more than once, you may need to pluralize the words, and you will not use all of the words Algorithm Assembly language BigInteger Compiler Constant Constructor double Exponent High level language Interpreted Keyword Mantissa Method Naming Convention null Object Parameter Primitive type Reference type Return Type Runnable String Target Machine Typecast 1. Real numbers are stored with a(n) and a(n) 2. If the compiler knows how much space a type requires, that is a . 3. If a variable is of a , the compiler allocates space for a pointer when the variable is declared. 4. Objects get created by methods called . 5. A pointer that has not been given a value contains the value 6. Types that the compiler knows about are . Code Constructs 7. (1 points each) What type of statement do you use for each of these situations: (a) to create a variable (b) to give a variable a value (c) to choose to do something or not do it (d) to do something more than once (e) to allocate space 8. (2 points) What is an instance variable? 9. (2 points) How do you know a method is a constructor? Be The Machine 10. (4 points) Draw the memory diagram for the following code snippet int x; double [] x = new double [6]; x[2] = 42; 11. (4 points) What is the output from this code snippet? for (int i = 4; i <= 7;="" i++)="" {="" for="" (int="" k="5," k=""> 0; k = k - 2) { System.out.print(i + ", " + k); if (i%3 == 1) { System.out.print(" MAGIC !!!!!"); } System.out.println (); } } For the question, suppose we have the following class declaration public class PerfectThing { private int clean; public PerfectThing(int hold) { clean = hold; } public int getTheMagic () { return hold * 42; } public void setClean(int nextClean) { clean = nextClean; } } 12. (4 points) Draw the memory diagram for this code snippet PerfectThing x = new PerfectThing (2); PerfectThing y = new PerfectThing (4); y = x; y.setClean (-1); SWE100 Final Exam Part 2 Vocabulary - 1 pt each Use the following words to fill in the blanks in this section. Note: you can use words more than once, you may need to pluralize the words, and you will not use all of the words Annotation Benchmarking Best case analysis Big-Oh Border Case Count-Controlled Loop DeMorgan’s Law Early Exit Condition Lifetime Method Variable Nested Conditional Response Time Scope Selection Sort Sentinel-Controlled Loop Short-cutting evaluation Sorting Problem TDD this Worst Case Analysis 1. We focus our tests on because that is where bugs are most likely to occur 2. The portion of our code that can see a variable is called 3. We generally use a for loop to implement a . 4. is one algorithm that solves the . 5. The theoretical run-time of an algorithm is denoted by no- tation. 6. is useful if we are trying to negate a complex conditional. 7. Sometimes, the compiler will skip the computation of part of a conditional because it knows that the value of that conditional won’t change. We call this . Short Answer 8. (3 points) Give three reasons for creating a method 9. (4 points) Write the code to declare a variable named var1 that can hold a character and give it the value of the character ’1’. 10. (1 points each) What type of statement do you use for each of these situations: (a) choosing between two possible options (b) count-controlled loops (c) sentinel-controlled loops (d) choosing not to do one possible option (e) marking a method as a test (f) marking a method so it is run before each test in a test class Code Constructs 11. (2 points) Suppose you have a character variable named ch. Give a conditional expression that will be true if ch contains a lower case letter. 12. (2 points) Suppose you have a character variable named ch that you know contains a lower case letter. Give an assignment statement that will convert it to upper case. 13. (2 points) Suppose you have a character variable named ch. Give a conditional expression that will be true if ch contains a digit. 14. (6 points) Suppose you are building a method that takes an integer parameter. If that parameter is greater than 100, it returns 42. Otherwise, it returns 16. Write a JUnit test that will test that border case. 15. (2 points each) Define what each of the following String methods does (a) charAt(i) (b) substring(i) (c) substring(i,j) (d) length() {give me the units of the result - you can’t just say it gives the length of the string!]} 16. (3 points) What is the difference between == and the equals() method when we are comparing objects? 17. (4 points) Show the swaps made by Selection Sort on this data: 4, 8, 10, 3, 6, 12 SWE100 Final Exam Part 3 Vocabulary - 1 pt each Use the following words to fill in the blanks in this section. Note: you can use words more than once, you may need to pluralize the words, and you will not use all of the words Ancestor Check Digit Class Diagram Datamining Exception extends Feature Selection Frame Bit Inheritance Is-A Method Signature Overload Override Parity Bit Parent Class Polymorphism Prompt Scanner Subclass Substitution Principle Super Class throw throws Token try/catch Two-Dimensional Array UML 1. We mark a class as being a subclass using the keyword . 2. In our zip code encoding, the made the sum of all of the digits be a multiple of 10. 3. We use the class to get input from a user and to read from a file. 4. An object of the child class object of the parent class because they must obey the 5. a method is where we have two methods with the same name in the same class while is when a child class has a different implementation for a method than the one it should inherit from its parent class. 6. is the class we use to read from a file or from the keyboard. Short Answer 7. (2 points) Explain why 1010 is 9 in zip codes. 8. (4 points) What is the difference between the keywords throw and throws? 9. (3 points) How do we test to make sure that an exception gets thrown? 10. (4 points) If x is the following two-dimensional array, what is the output from the following code? for (int i = 0; i<5; i++) { sum = sum + x[i][2]; } system.out.println(sum); 11. (2 points) what does it mean for a class to be abstract? 12. (2 points each) suppose our rigged constructor was passed this information: string [] ingredients = {"salt","rosemary","pepper","beef", "pepper","thyme","eggs"}; string [] cuisines = {"italian","good food", "korean","icky food", "mexican","homecooking"}; string [] recipecuisine = {"good food", "good food", "korean","korean","italian","homecooking"}; boolean [][] recipeingredients = {{true , false , true , false}, {false , true , false , false}, {true , true , true , true}, {true , false , true , true}, {false , false , false , false}, {true , false , false , true }}; recipedata r = new recipedata(cuisines , ingredients , recipecuisine , recipeingredients ); what would be the value of each of the following? (a) r.getnumberofsamples() (b) r.getnumberofcuisines() (c) r.getnumberofingredients() (d) r.getrecipeingredient(0, 0) (e) r.getrecipeingredient(3, 1) (f) r.getmutualinformation(1, 3) 13. (3 points) what is inheritance? 14. (3 points) explain why you could not run testlifeform. 15. (2 points) if we can’t run testlifeform, why did we build it? the following questions refer to this class diagram: 16. (2 points) in this diagram, which class inherits from the other? 17. (2 points) which method is overridden by the child class? 18. (2 points) if we create an instance of generalclass, how many instance variables will it have? 19. (2 points) if we create an instance of specificclass, how many instance variables will it have? 20. (2 points) how many test classes should you create if you were building these classes? 1 real numbers are stored with an: and an: 2 if the compiler knows how much space a type requires that is a: 3 if a variable is of a: 4 objects get created by methods called: 5 a pointer that has not been given a value contains the value: 6 types that the compiler knows about are: 1 we focus our tests on: 2 the portion of our code that can see a variable is called: 3 we generally use a for loop to implement a: 4: is one algorithm that solves the: 5 the theoretical runtime of an algorithm is denoted by: 6: knows that the value of that conditional wont change we call this: 1 we mark a class as being a subclass using the keyword: 2 in our zip code encoding the: 3 we use the: 4 an object of the child class: they must obey the: 5: in the same class while: 6_2: text1: text2: text3: text4: text5: text6: text7: image8_af_image: text9: image10_af_image: text11: text12: text13: text14: text15: text16: text17: text18: text19: text20: text21: text22: text23: text24: text25: text26: text27: text28: text29: text30: text31: text32: text33: text34: text35: text36: text37: text38: text39: text40: text41: text42: text43: text44: text45: text46: text47: i++)="" {="" sum="sum" +="" x[i][2];="" }="" system.out.println(sum);="" 11.="" (2="" points)="" what="" does="" it="" mean="" for="" a="" class="" to="" be="" abstract?="" 12.="" (2="" points="" each)="" suppose="" our="" rigged="" constructor="" was="" passed="" this="" information:="" string="" []="" ingredients="{"salt","rosemary","pepper","beef"," "pepper","thyme","eggs"};="" string="" []="" cuisines="{"italian","good" food",="" "korean","icky="" food",="" "mexican","homecooking"};="" string="" []="" recipecuisine="{"good" food",="" "good="" food",="" "korean","korean","italian","homecooking"};="" boolean="" [][]="" recipeingredients="{{true" ,="" false="" ,="" true="" ,="" false},="" {false="" ,="" true="" ,="" false="" ,="" false},="" {true="" ,="" true="" ,="" true="" ,="" true},="" {true="" ,="" false="" ,="" true="" ,="" true},="" {false="" ,="" false="" ,="" false="" ,="" false},="" {true="" ,="" false="" ,="" false="" ,="" true="" }};="" recipedata="" r="new" recipedata(cuisines="" ,="" ingredients="" ,="" recipecuisine="" ,="" recipeingredients="" );="" what="" would="" be="" the="" value="" of="" each="" of="" the="" following?="" (a)="" r.getnumberofsamples()="" (b)="" r.getnumberofcuisines()="" (c)="" r.getnumberofingredients()="" (d)="" r.getrecipeingredient(0,="" 0)="" (e)="" r.getrecipeingredient(3,="" 1)="" (f)="" r.getmutualinformation(1,="" 3)="" 13.="" (3="" points)="" what="" is="" inheritance?="" 14.="" (3="" points)="" explain="" why="" you="" could="" not="" run="" testlifeform.="" 15.="" (2="" points)="" if="" we="" can’t="" run="" testlifeform,="" why="" did="" we="" build="" it?="" the="" following="" questions="" refer="" to="" this="" class="" diagram:="" 16.="" (2="" points)="" in="" this="" diagram,="" which="" class="" inherits="" from="" the="" other?="" 17.="" (2="" points)="" which="" method="" is="" overridden="" by="" the="" child="" class?="" 18.="" (2="" points)="" if="" we="" create="" an="" instance="" of="" generalclass,="" how="" many="" instance="" variables="" will="" it="" have?="" 19.="" (2="" points)="" if="" we="" create="" an="" instance="" of="" specificclass,="" how="" many="" instance="" variables="" will="" it="" have?="" 20.="" (2="" points)="" how="" many="" test="" classes="" should="" you="" create="" if="" you="" were="" building="" these="" classes?="" 1="" real="" numbers="" are="" stored="" with="" an:="" and="" an:="" 2="" if="" the="" compiler="" knows="" how="" much="" space="" a="" type="" requires="" that="" is="" a:="" 3="" if="" a="" variable="" is="" of="" a:="" 4="" objects="" get="" created="" by="" methods="" called:="" 5="" a="" pointer="" that="" has="" not="" been="" given="" a="" value="" contains="" the="" value:="" 6="" types="" that="" the="" compiler="" knows="" about="" are:="" 1="" we="" focus="" our="" tests="" on:="" 2="" the="" portion="" of="" our="" code="" that="" can="" see="" a="" variable="" is="" called:="" 3="" we="" generally="" use="" a="" for="" loop="" to="" implement="" a:="" 4:="" is="" one="" algorithm="" that="" solves="" the:="" 5="" the="" theoretical="" runtime="" of="" an="" algorithm="" is="" denoted="" by:="" 6:="" knows="" that="" the="" value="" of="" that="" conditional="" wont="" change="" we="" call="" this:="" 1="" we="" mark="" a="" class="" as="" being="" a="" subclass="" using="" the="" keyword:="" 2="" in="" our="" zip="" code="" encoding="" the:="" 3="" we="" use="" the:="" 4="" an="" object="" of="" the="" child="" class:="" they="" must="" obey="" the:="" 5:="" in="" the="" same="" class="" while:="" 6_2:="" text1:="" text2:="" text3:="" text4:="" text5:="" text6:="" text7:="" image8_af_image:="" text9:="" image10_af_image:="" text11:="" text12:="" text13:="" text14:="" text15:="" text16:="" text17:="" text18:="" text19:="" text20:="" text21:="" text22:="" text23:="" text24:="" text25:="" text26:="" text27:="" text28:="" text29:="" text30:="" text31:="" text32:="" text33:="" text34:="" text35:="" text36:="" text37:="" text38:="" text39:="" text40:="" text41:="" text42:="" text43:="" text44:="" text45:="" text46:="">
May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here