CS 159 Midterm #1 Review Questions
|
|
- Richard Bradley
- 6 years ago
- Views:
Transcription
1 1. Given the following declarations: boolean checked ; double price ; double [] weights ; String [] eids ; CS 159 Midterm #1 Review Questions indicate whether each of the following is a value type or a reference type. (a) checked (b) price v v (c) weights r (d) weights[0] (e) eids v r (f) eids[0] r (g) eids[0].length() v (h) eids.length v (i) eids[0].charat(1) v (j) "president@jmu.edu" r 2. Given the following Animation class: public class Animation public void play () System. out. println ("I don t know how!");
2 CS 159 Midterm #1 Review Questions Page 2 of 14 and the following application: public class Bad public static void main ( String [] arguments ) int i; if (( arguments. length > 0) ( arguments!= null )) System. out. println ( arguments [0]); System. out. println ( arguments [ arguments. length ]); i = 1; j = 2; ++i; Animation. play (); (a) Put an N next to all of the statements that will not compile (i.e., next to all of the statements that have syntactic defects) in the Bad class. (b) Put an X next to all of the statements that will compile but will definitely generate an exception at run-time (i.e., faults that will definitely cause a failure at run-time). (c) Put a? next to all of that statements that will compile and may, depending on the parameters, generate an exception at run-time. public class Animation public void play () System. out. println ("I don t know how!"); public class Bad public static void main ( String [] arguments ) int i; if (( arguments. length > 0) ( arguments!= null )) // This block will always be reached since arguments cannot // be null... System. out. println ( arguments [0]); //? fault if length is 0 System. out. println ( arguments [ arguments. length ]); // X i = 1; j = 2; // N ( j has not been declared ) ++i; Animation. play (); // N ( not a static method ) 3. Given the following paws() method in the Animal class: Page 2
3 CS 159 Midterm #1 Review Questions Page 3 of 14 public static void paws ( String [] a, String [] b) String [] temp ; temp = a; a = b; b = temp ; what would be printed by the following fragment? String [] u, v; u = new String [2]; u [0] = " German "; u [1] = " Shepherd "; v = new String [2]; v [0] = " Belgian "; v [1] = " Malinois "; Animal. paws (u, v); System. out. printf ("%s %s and %s %s\n", u[0], u[1], v[0], v [1]); German Shepherd and Belgian Malinois 4. Given the following implementation of the SoundModifier class: public class SoundModifier int b []; public SoundModifier ( int [] a) b = a; public void modify () int i; for (i =0; i<b. length ; i ++) b[i] = i *2; What will be printed by the following code fragment? public static void main ( String [] args ) int i; int [] tune ; SoundModifier m; tune = new int [5]; for (i =0; i <5; i ++) tune [ i] = 100; m = new SoundModifier ( tune ); m. modify (); for (i =0; i <5; i ++) Page 3
4 CS 159 Midterm #1 Review Questions Page 4 of 14 System. out. println ( tune [i ]); Page 4
5 CS 159 Midterm #1 Review Questions Page 5 of Given the following RunningTime and Movie classes: public class RunningTime public double hours, minutes ; public RunningTime ( double hrs, double mins ) hours = hrs ; minutes = mins ; public class Movie public RunningTime rt; public String title ; public Movie ( RunningTime length, String title ) rt = length ; this. title = title ; What will be printed by the following code fragment? (Note: Be careful!) public class Theater public static void main ( String [] args ) Movie frozen, matrix ; RunningTime length ; length = new RunningTime (2.0, 10.0); matrix = new Movie ( length, " The Matrix "); System. out. println ( matrix. title + ": " + matrix.rt. hours +" hrs "+ matrix.rt. minutes +" mins "); length. hours = 5.0; System. out. println ( matrix. title + ": " + matrix.rt. hours +" hrs "+ matrix.rt. minutes +" mins "); frozen = matrix ; frozen. title = " Frozen "; System. out. println ( matrix. title + ": " + matrix.rt. hours +" hrs "+ matrix.rt. minutes +" mins "); System. out. println ( frozen. title + ": " + frozen.rt. hours +" hrs "+ frozen.rt. minutes +" mins "); The Matrix: 2.0hrs 10.0mins The Matrix: 5.0hrs 10.0mins Page 5
6 CS 159 Midterm #1 Review Questions Page 6 of 14 Frozen: 5.0hrs 10.0mins Frozen: 5.0hrs 10.0mins Page 6
7 CS 159 Midterm #1 Review Questions Page 7 of Given the following Contact class: public class Contact private int extension ; private String [] info ; public Contact ( String [] info, int extension ) this. info = info ; this. extension = extension ; public String tostring () String result ; result = " Contact :\n"; for ( int i =0; i< info. length ; i ++) result += info [i] + "\n"; result += " x" + extension + "\ n"; return result ; what will be printed by the following code fragment? (Note: Be careful!) public class Driver public static void main ( String [] args ) Contact [] contacts ; String [] text ; contacts = new Contact [3]; text = new String [2]; text [0] = new String (" Prof. Bernstein "); text [1] = new String (" Room 257 "); contacts [0] = new Contact ( text, 1671); System. out. println ( contacts [0]. tostring ()); text [0] = new String (" Prof. Mayfield "); text [1] = new String (" Room 208 "); contacts [1] = new Contact ( text, 3314); System. out. println ( contacts [1]. tostring ()); text [0] = new String (" Prof. Sprague "); text [1] = new String (" Room 226 "); contacts [2] = new Contact ( text, 3312); System. out. println ( contacts [2]. tostring ()); System. out. println (" Everybody "); for ( int i =0; i< contacts. length ; i ++) System. out. println ( contacts [i]. tostring ()); Page 7
8 CS 159 Midterm #1 Review Questions Page 8 of 14 Contact: Prof. Bernstein Room 257 x1671 Contact: Prof. Mayfield Room 208 x3314 Contact: Prof. Sprague Room 226 x3312 Everybody Contact: Prof. Sprague Room 226 x1671 Contact: Prof. Sprague Room 226 x3314 Contact: Prof. Sprague Room 226 x3312 Page 8
9 CS 159 Midterm #1 Review Questions Page 9 of Consider the following UML diagram of the Coin and Metal classes. (a) Write the declaration (only) of the attribute named weight. private double weight; (b) Write the declaration (only) of the explicit value constructor. public Coin(double weight, String metal) (c) Implement the getweight() method. public double getweight() return weight; (d) Assuming the UML diagram is a complete specification of the class, are Coin objects mutable or immutable? Immutable. (e) Write the declaration (only) of the totalweight() method. public static double totalweight(coin[] coins, String target) throws IllegalArgumentException Note: The throws clause is not actually required because IllegalArgumentException is not a checked exception. (f) Write a statement (in the totalweight() method) that checks to see if memory has been allocated for the parameter name coins and throws the appropriate exception if it has not been. if (coins == null) throw new IllegalArgumentException("Null coin array."); (g) Assuming that the explicit value constructor in the Coin class includes the following statement: this.metal = new String(metal); what will the expression (target == coins[i].getmetal()) in the totalweight() if the actual parameter corresponding to target is "Gold", and coins[i].getmetal() returns "Gold"? Page 9
10 CS 159 Midterm #1 Review Questions Page 10 of 14 The expression will evaluate to false since these will be two different String objects. 8. Given the Coin and Metal classes from the previous question: (a) Write the declaration for a local variable named copper that can contain a double value. double copper; (b) Write the declaration for a local variable named penny that is a (reference to) a Coin object. Coin penny; (c) Write the declaration for a local variable named found that is a (reference to) an array of Coin objects. Coin[] found; (d) Write a statement that allocates enough memory for found to hold (references to) 100 Coin objects. found = new Coin[100]; (e) Write a statement that assigns penny to element 3 of found. found[3] = penny; (f) Write a statement that calls totalweight(), passes it found and the String literal "Copper", and assigns the result to the variable named copper. copper = totalweight(found, "Copper"); Page 10
11 CS 159 Midterm #1 Review Questions Page 11 of Construct the following utility class. In addition to the specifications that are contained in the UML diagram, the categorycount() method must comply with the following specifications. 1. Parameter Validation (a) If memory was not allocated for the actual parameter corresponding to the formal parameter named sides then it must throw an IllegalArgumentException. 2. Operation (a) For any element of sides that is less than 3 it must use 3 plus the absolute value of that element. (b) It must calculate the number of elements in the parameter named sides that are odd and the number of elements in the parameter named sides that are even. For example, for the array 3,1,4,7,5,-2 (corresponding to a triangle, invalid value, quadrilateral, heptagon, pentagon, and another invalid value) there are two elements with an even number of sides (using the value 4 in place of the 1) and four with an odd number of sides (using the value 5 in place of the -2). (c) It must return the String containing the number of elements that are odd followed by the number of elements that are even. (d) It must not change the elements of the sides array in any way (i.e., it must have no side effects). 3. Format of the Returned String (a) The number of odd sides and the number of even sides must each be in a field of width 4 (with no decimal point since they are integers). (b) There must be a slash (i.e., a / character between the number of odd sides and the number of even sides. public static String categorycount(int[] sides) if (sides == null) throw new IllegalArgumentException("sides array is null."); int evencount = 0; String result; for (int cursides : sides) if (cursides < 3) cursides = Math.abs(curSides) + 3; if (cursides % 2 == 0) evencount++; result = String.format("%4d/%4d", sides.length - evencount, evencount); return result; Page 11
12 CS 159 Midterm #1 Review Questions Page 12 of Professors often like to leave empty seats between students on exam days. One way to ensure that at least every-other seat is empty along both the row and column dimensions is to ensure that in even-numbered rows the even-numbered columns are empty and that in odd-numbered rows the odd-numbered columns are empty. Assuming the SeatingChart class contains the following attribute: private Student[][] seats and assuming a seat is empty if the corresponding element of this array is null, write a method (in the SeatingChart class) with the following signature: public boolean okforexams() that returns true if and only if this specification is satisfied. public boolean okfortests() for (int row = 0; row < getrows(); row++) int col = 0; if (row % 2!= 0) col = 1; // for odd rows, start at col 1 for (; col < getcolumns(); col += 2) if (seats[row][col]!= null) return false; return true; 11. Lecture rooms are often deeper than they are wide, while lab rooms are often wider than they are deep. Serendipitously, for CS111 this semester, the lecture room has N rows and M columns and the lab room has M rows and N columns. To that end, write a method with the following signature: public static Student[][] transpose(student[][] seats) that constructs and returns an array of arrays in which the student in element (n, m) of the parameter is in element (m, n) of the result. (Note: You should assume that the array of arrays is rectangular.) public static Student[][] transpose(student[][] seats) Student[][] transposed; Page 12
13 CS 159 Midterm #1 Review Questions Page 13 of 14 // seats argument must have at least one row. transposed = new Student[seats[0].length][seats.length]; for (int row = 0; row < seats.length; row++) for (int col = 0; col < seats[0].length; col++) transposed[col][row] = seats[row][col]; return transposed; Page 13
14 CS 159 Midterm #1 Review Questions Page 14 of To support the development of unit tests for a new version of the SeatingChart class it will be helpful to have a method that verifies the dimensions of a rectangular array of arrays (a.k.a., a rectangular two-dimensional array). To that end, implement a checkshape() method with the following signature: public static boolean checkshape(student[][] seats, int rows, int cols) Your implementation must satisfy the following requirements: It must return false if: 1. Memory has not been allocated for seats. 2. The number of rows in seats does not match the rows argument. 3. Any row is null. 4. Any row in has a number of columns that does not match cols. Otherwise, it must return true. public static boolean checkshape(student[][] seats, int rows, int cols) if (seats == null seats.length!= rows) return false; for (int row = 0; row < seats.length; row++) if (seats[row] == null seats[row].length!= cols) return false; return true; Page 14
CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University
9/5/6 CS Introduction to Computing II Wayne Snyder Department Boston University Today: Arrays (D and D) Methods Program structure Fields vs local variables Next time: Program structure continued: Classes
More informationCS 139 Practice Midterm Questions #2
CS 139 Practice Midterm Questions #2 Spring 2016 Name: 1. Write Java statements to accomplish each of the following. (a) Declares numbers to be an array of int s. (b) Initializes numbers to contain a reference
More informationSPRING 13 CS 0007 FINAL EXAM V2 (Roberts) Your Name: A pt each. B pt each. C pt each. D or 2 pts each
Your Name: Your Pitt (mail NOT peoplesoft) ID: Part Question/s Points available Rubric Your Score A 1-6 6 1 pt each B 7-12 6 1 pt each C 13-16 4 1 pt each D 17-19 5 1 or 2 pts each E 20-23 5 1 or 2 pts
More informationCS159. Nathan Sprague. September 11, 2015
CS159 Nathan Sprague September 11, 2015 Review of Arrays Declaration: int[] numbers; String[] words; Review of Arrays Declaration: int[] numbers; String[] words; Instantiation: numbers = new int[4]; words
More informationPractice exam for CMSC131-04, Fall 2017
Practice exam for CMSC131-04, Fall 2017 Q1 makepalindrome - Relevant topics: arrays, loops Write a method makepalidrome that takes an int array, return a new int array that contains the values from the
More informationPace University. Fundamental Concepts of CS121 1
Pace University Fundamental Concepts of CS121 1 Dr. Lixin Tao http://csis.pace.edu/~lixin Computer Science Department Pace University October 12, 2005 This document complements my tutorial Introduction
More informationClasses Classes 2 / 36
Classes 1 / 36 Classes Classes 2 / 36 Anatomy of a Class By the end of next lecture, you ll understand everything in this class definition. package edu. gatech. cs1331. card ; import java. util. Arrays
More informationCS159 Midterm #1 Review
Name: CS159 Midterm #1 Review 1. Choose the best answer for each of the following multiple choice questions. (a) What is the effect of declaring a class member to be static? It means that the member cannot
More informationCS159. Nathan Sprague
CS159 Nathan Sprague What s wrong with the following code? 1 /* ************************************************** 2 * Return the mean, or -1 if the array has length 0. 3 ***************************************************
More information1 Short Answer (15 Points Each)
Name: Write all of your responses on these exam pages. If you need extra space please use the backs of the pages. 1 Short Answer (15 Points Each) 1. Write the following Java declarations, (a) A double
More informationCHAPTER 7 OBJECTS AND CLASSES
CHAPTER 7 OBJECTS AND CLASSES OBJECTIVES After completing Objects and Classes, you will be able to: Explain the use of classes in Java for representing structured data. Distinguish between objects and
More informationpublic static boolean isoutside(int min, int max, int value)
See the 2 APIs attached at the end of this worksheet. 1. Methods: Javadoc Complete the Javadoc comments for the following two methods from the API: (a) / @param @param @param @return @pre. / public static
More informationCIS 120 Midterm II November 8, Name (printed): Pennkey (login id):
CIS 120 Midterm II November 8, 2013 Name (printed): Pennkey (login id): My signature below certifies that I have complied with the University of Pennsylvania s Code of Academic Integrity in completing
More informationSelected Questions from by Nageshwara Rao
Selected Questions from http://way2java.com by Nageshwara Rao Swaminathan J Amrita University swaminathanj@am.amrita.edu November 24, 2016 Swaminathan J (Amrita University) way2java.com (Nageshwara Rao)
More informationExam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming
Exam 1 Prep Dr. Demetrios Glinos University of Central Florida COP3330 Object Oriented Programming Progress Exam 1 is a Timed Webcourses Quiz You can find it from the "Assignments" link on Webcourses choose
More informationCS 149. Professor: Alvin Chao
CS 149 Professor: Alvin Chao CS149 More with Classes and Objects OverLoading Let's look at the Car class... Terminology Method definition public void accelerate(double amount) { speed += amount; if (speed
More informationMcGill University School of Computer Science COMP-202A Introduction to Computing 1
McGill University School of Computer Science COMP-202A Introduction to Computing 1 Midterm Exam Thursday, October 26, 2006, 18:00-20:00 (6:00 8:00 PM) Instructors: Mathieu Petitpas, Shah Asaduzzaman, Sherif
More informationFramework Fundamentals
Questions Framework Fundamentals 1. Which of the following are value types? (Choose all that apply.) A. Decimal B. String C. System.Drawing.Point D. Integer 2. Which is the correct declaration for a nullable
More informationESC101 : Fundamental of Computing
ESC101 : Fundamental of Computing End Semester Exam 19 November 2008 Name : Roll No. : Section : Note : Read the instructions carefully 1. You will lose 3 marks if you forget to write your name, roll number,
More informationCHAPTER 7 OBJECTS AND CLASSES
CHAPTER 7 OBJECTS AND CLASSES OBJECTIVES After completing Objects and Classes, you will be able to: Explain the use of classes in Java for representing structured data. Distinguish between objects and
More informationComputer Science II Data Structures
Computer Science II Data Structures Instructor Sukumar Ghosh 201P Maclean Hall Office hours: 10:30 AM 12:00 PM Mondays and Fridays Course Webpage homepage.cs.uiowa.edu/~ghosh/2116.html Course Syllabus
More informationCS 113 MIDTERM EXAM 2 SPRING 2013
CS 113 MIDTERM EXAM 2 SPRING 2013 There are 18 questions on this test. The value of each question is: 1-15 multiple choice (3 pts) 17 coding problem (15 pts) 16, 18 coding problems (20 pts) You may get
More informationCS111: PROGRAMMING LANGUAGE II
1 CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1: Introduction Lecture Contents 2 Course info Why programming?? Why Java?? Write once, run anywhere!! Java basics Input/output Variables
More informationComputer Sciences 302 Exam 2 Information & Sample Exam
Computer Sciences 302 Exam 2 Information & Sample Exam Below you ll find information about the second midterm exam and sample exam questions. This sample is intended to be similar in length and difficulty
More informationSession 04 - Object-Oriented Programming 1 Self-Assessment
UC3M Alberto Cortés Martín Systems Programming, 2014-2015 version: 2015-02-06 Session 04 - Object-Oriented Programming 1 Self-Assessment Exercise 1 Rectangles Part 1.A Write a class called Rectangle1 that
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationFaculty of Science COMP-202A - Introduction to Computing I (Fall 2008) Midterm Examination
First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202A - Introduction to Computing I (Fall 2008) Midterm Examination Tuesday, November 4, 2008 Examiners: Mathieu Petitpas [Section 1] 18:30
More informationSubclassing for ADTs Implementation
Object-Oriented Design Lecture 8 CS 3500 Fall 2009 (Pucella) Tuesday, Oct 6, 2009 Subclassing for ADTs Implementation An interesting use of subclassing is to implement some forms of ADTs more cleanly,
More informationArray. Prepared By - Rifat Shahriyar
Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types
More informationFor Teacher's Use Only Q No Total Q No Q No
Student Info Student ID: Center: Exam Date: FINALTERM EXAMINATION Spring 2010 CS201- Introduction to Programming Time: 90 min Marks: 58 For Teacher's Use Only Q No. 1 2 3 4 5 6 7 8 Total Marks Q No. 9
More informationExam Duration: 2hrs and 30min Software Design
Exam Duration: 2hrs and 30min. 433-254 Software Design Section A Multiple Choice (This sample paper has less questions than the exam paper The exam paper will have 25 Multiple Choice questions.) 1. Which
More informationCMSC131 Final Exam Practice Questions
CMSC131 Final Exam Practice Questions Disclaimer: The following are questions that try to provide you with some practice material for the final exam. By no means do they represent the only material you
More informationCS61BL. Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling
CS61BL Lecture 1: Welcome to CS61BL! Intro to Java and OOP Testing Error-handling About me Name: Edwin Liao Email: edliao@berkeley.edu Office hours: Thursday 3pm - 5pm Friday 11am - 1pm 611 Soda Or by
More informationComputer Programming: C++
The Islamic University of Gaza Engineering Faculty Department of Computer Engineering Fall 2017 ECOM 2003 Muath i.alnabris Computer Programming: C++ Experiment #7 Arrays Part II Passing Array to a Function
More informationFinal exam. Final exam will be 12 problems, drop any 2. Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers)
Review Final exam Final exam will be 12 problems, drop any 2 Cumulative up to and including week 14 (emphasis on weeks 9-14: classes & pointers) 2 hours exam time, so 12 min per problem (midterm 2 had
More informationCS 101 Spring 2006 Final Exam Name: ID:
This exam is open text book but closed-notes, closed-calculator, closed-neighbor, etc. Unlike the midterm exams, you have a full 3 hours to work on this exam. Please sign the honor pledge here: Page 1
More informationCOS 126 General Computer Science Spring Written Exam 1
COS 126 General Computer Science Spring 2017 Written Exam 1 This exam has 9 questions (including question 0) worth a total of 70 points. You have 50 minutes. Write all answers inside the designated spaces.
More informationCMSC 433 Section 0101 Fall 2012 Midterm Exam #1
Name: CMSC 433 Section 0101 Fall 2012 Midterm Exam #1 Directions: Test is closed book, closed notes. Answer every question; write solutions in spaces provided. Use backs of pages for scratch work. Good
More informationCS 307 Midterm 1 Spring 2009
Points off 1 2 3 4 Total off Net Score CS 307 Midterm 1 Spring 2009 Your Name Your UTEID Circle yours TA s name: Todd Guhan Xiuming(aka David) Instructions: 1. Please turn off or silence your cell phones.
More informationComputer Sciences 302 Final Exam Information & Sample Questions
Computer Sciences 302 Final Exam Information & Sample Questions Below you ll find information about the final exam and sample exam questions. This sampling does not represent the length or difficulty of
More informationboolean, char, class, const, double, else, final, float, for, if, import, int, long, new, public, return, static, throws, void, while
CSCI 150 Fall 2007 Java Syntax The following notes are meant to be a quick cheat sheet for Java. It is not meant to be a means on its own to learn Java or this course. For that you should look at your
More informationLecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Lecture 13. Notation. The rules. Evaluation Rules So Far
Lecture Outline Operational Semantics of Cool Lecture 13 COOL operational semantics Motivation Notation The rules Prof. Aiken CS 143 Lecture 13 1 Prof. Aiken CS 143 Lecture 13 2 Motivation We must specify
More informationClasses Classes 2 / 35
Classes 1 / 35 Classes Classes 2 / 35 Anatomy of a Class By the end of next lecture, you ll understand everything in this class definition. package edu. gatech. cs1331. card ; import java. util. Arrays
More informationCS159. Nathan Sprague. September 30, 2015
CS159 Nathan Sprague September 30, 2015 Testing Happens at Multiple Levels Unit Testing - Test individual classes in isolation. Focus is on making sure that each method works according to specification.
More informationFinal Exam Practice. Partial credit will be awarded.
Please note that this problem set is intended for practice, and does not fully represent the entire scope covered in the final exam, neither the range of the types of problems that may be included in the
More informationCMPSCI 187: Programming With Data Structures. Lecture 12: Implementing Stacks With Linked Lists 5 October 2011
CMPSCI 187: Programming With Data Structures Lecture 12: Implementing Stacks With Linked Lists 5 October 2011 Implementing Stacks With Linked Lists Overview: The LinkedStack Class from L&C The Fields and
More informationMidterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total.
Midterm I - CSE11 Fall 2013 CLOSED BOOK, CLOSED NOTES 50 minutes, 100 points Total. Name: ID: Problem 1) (8 points) For the following code segment, what are the values of i, j, k, and d, after the segment
More informationAdministration. Exceptions. Leftovers. Agenda. When Things Go Wrong. Handling Errors. CS 99 Summer 2000 Michael Clarkson Lecture 11
Administration Exceptions CS 99 Summer 2000 Michael Clarkson Lecture 11 Lab 10 due tomorrow No lab tomorrow Work on final projects Remaining office hours Rick: today 2-3 Michael: Thursday 10-noon, Monday
More informationData abstractions: ADTs Invariants, Abstraction function. Lecture 4: OOP, autumn 2003
Data abstractions: ADTs Invariants, Abstraction function Lecture 4: OOP, autumn 2003 Limits of procedural abstractions Isolate implementation from specification Dependency on the types of parameters representation
More informationMidterm Exam CS 251, Intermediate Programming October 8, 2014
Midterm Exam CS 251, Intermediate Programming October 8, 2014 Name: NetID: Answer all questions in the space provided. Write clearly and legibly, you will not get credit for illegible or incomprehensible
More informationCS111: PROGRAMMING LANGUAGE II
CS111: PROGRAMMING LANGUAGE II Computer Science Department Lecture 1(c): Java Basics (II) Lecture Contents Java basics (part II) Conditions Loops Methods Conditions & Branching Conditional Statements A
More informationSubclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented
Table of Contents L01 - Introduction L02 - Strings Some Examples Reserved Characters Operations Immutability Equality Wrappers and Primitives Boxing/Unboxing Boxing Unboxing Formatting L03 - Input and
More information3. Convert 2E from hexadecimal to decimal. 4. Convert from binary to hexadecimal
APCS A Midterm Review You will have a copy of the one page Java Quick Reference sheet. This is the same reference that will be available to you when you take the AP Computer Science exam. 1. n bits can
More informationFaculty of Science COMP-202B - Introduction to Computing I (Winter 2009) Midterm Examination
First Name: Last Name: McGill ID: Section: Faculty of Science COMP-202B - Introduction to Computing I (Winter 2009) Midterm Examination Monday, March 9, 2009 Examiners: Mathieu Petitpas [Section 1] 18:30
More informationChapter 4 Defining Classes I
Chapter 4 Defining Classes I This chapter introduces the idea that students can create their own classes and therefore their own objects. Introduced is the idea of methods and instance variables as the
More informationArrays. Outline 1/7/2011. Arrays. Arrays are objects that help us organize large amounts of information. Chapter 7 focuses on:
Arrays Arrays Arrays are objects that help us organize large amounts of information Chapter 7 focuses on: array declaration and use bounds checking and capacity arrays that store object references variable
More informationFORM 2 (Please put your name and form # on the scantron!!!!)
CS 161 Exam 2: FORM 2 (Please put your name and form # on the scantron!!!!) True (A)/False(B) (2 pts each): 1. Recursive algorithms tend to be less efficient than iterative algorithms. 2. A recursive function
More informationAnnouncements. CS18000: Problem Solving And Object-Oriented Programming
Announcements Exam 1 Monday, February 28 Wetherill 200, 4:30pm-5:20pm Coverage: Through Week 6 Project 2 is a good study mechanism Final Exam Tuesday, May 3, 3:20pm-5:20pm, PHYS 112 If you have three or
More information2 2
1 2 2 3 3 C:\Temp\Templates 4 5 Use This Main Program 6 # include "Utilities.hpp" # include "Student.hpp" Copy/Paste Main void MySwap (int Value1, int Value2); int main(int argc, char * argv[]) { int A
More informationENGR 2710U Midterm Exam UOIT SOLUTION SHEET
SOLUTION SHEET ENGR 2710U: Object Oriented Programming & Design Midterm Exam October 19, 2012, Duration: 80 Minutes (9 Pages, 14 questions, 100 Marks) Instructor: Dr. Kamran Sartipi Name: Student Number:
More informationQueens College, CUNY Department of Computer Science. CS 212 Object-Oriented Programming in Java Practice Exam 2. CS 212 Exam 2 Study Guide
Topics for Exam 2: Queens College, CUNY Department of Computer Science CS 212 Object-Oriented Programming in Java Practice Exam 2 CS 212 Exam 2 Study Guide Linked Lists define a list node define a singly-linked
More informationInheritance (Part 5) Odds and ends
Inheritance (Part 5) Odds and ends 1 Static Methods and Inheritance there is a significant difference between calling a static method and calling a non-static method when dealing with inheritance there
More informationFinal Exam CS 152, Computer Programming Fundamentals December 9, 2016
Final Exam CS 152, Computer Programming Fundamentals December 9, 2016 Name: NetID: Answer all questions in the space provided. Write clearly and legibly, you will not get credit for illegible or incomprehensible
More information1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4'
Practice questions: 1. Which of the following is the correct expression of character 4? a. 4 b. "4" c. '\0004' d. '4' 2. Will System.out.println((char)4) display 4? a. Yes b. No 3. The expression "Java
More informationExamination Questions Midterm 1
CS1102s Data Structures and Algorithms 10/2/2010 Examination Questions Midterm 1 This examination question booklet has 9 pages, including this cover page, and contains 15 questions. You have 40 minutes
More informationCSE 331 Midterm Exam 2/13/12
Name There are 10 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes, closed
More informationArrays. COMS W1007 Introduction to Computer Science. Christopher Conway 10 June 2003
Arrays COMS W1007 Introduction to Computer Science Christopher Conway 10 June 2003 Arrays An array is a list of values. In Java, the components of an array can be of any type, basic or object. An array
More informationPractice Midterm 1. Problem Points Score TOTAL 50
CS 120 Software Design I Spring 2019 Practice Midterm 1 University of Wisconsin - La Crosse February 25 NAME: Do not turn the page until instructed to do so. This booklet contains 10 pages including the
More informationMidterm Exam CS 251, Intermediate Programming March 6, 2015
Midterm Exam CS 251, Intermediate Programming March 6, 2015 Name: NetID: Answer all questions in the space provided. Write clearly and legibly, you will not get credit for illegible or incomprehensible
More informationActivity 4: Methods. Content Learning Objectives. Process Skill Goals
Activity 4: Methods Java programs are organized into classes, each of which has one or more methods, each of which has one or more statements. Writing methods allows you to break down a complex program
More informationBirkbeck (University of London) Software and Programming 1 In-class Test Mar 2018
Birkbeck (University of London) Software and Programming 1 In-class Test 2.1 22 Mar 2018 Student Name Student Number Answer ALL Questions 1. What output is produced when the following Java program fragment
More informationCSE-160 (Winter 2017, Kesden) Practice Midterm Exam. volatile int count = 0; // volatile just keeps count in mem vs register
Full Name: @ucsd.edu PID: CSE-160 (Winter 2017, Kesden) Practice Midterm Exam 1. Threads, Concurrency Consider the code below: volatile int count = 0; // volatile just keeps count in mem vs register void
More informationHAS-A Relationship. Association is a relationship where all objects have their own lifecycle and there is no owner.
HAS-A Relationship Association is a relationship where all objects have their own lifecycle and there is no owner. For example, teacher student Aggregation is a specialized form of association where all
More informationInitializers: Array initializers can be used with class base types as well. The elements of the initializer can be expressions (not just constants).
CMSC 131: Chapter 15 (Supplement) Arrays II Arrays of Objects Array of Objects: The base type of an array can be a class object. Example: Array of Strings. String[ ] greatcities = new String[5]; greatcities[2]
More informationPoints off Total off Net Score. CS 314 Final Exam Spring 2017
Points off 1 2 3 4 5 6 Total off Net Score CS 314 Final Exam Spring 2017 Your Name Your UTEID Instructions: 1. There are 6 questions on this test. 100 points available. Scores will be scaled to 300 points.
More informationUse the Scantron sheets to write your answer. Make sure to write your Purdue ID (NOT Purdue Login ID) and your name on the Scantron answer sheet.
Department of Computer Science Purdue University, West Lafayette Fall 2011: CS 180 Problem Solving and OO Programming Final Examination: Part A. You may consult the textbook and your hand written notes.
More informationAccount joeacct = new Account (100, new Account (500)); Account joeacct = new Account (100, new Account (500, null));
Exam information 369 students took the exam. Scores ranged from 1 to 20, with a median of 11 and an average of 11.1. There were 40 scores between 15.5 and 20, 180 between 10.5 and 15, 132 between 5.5 and
More informationI. True/False: (2 points each)
CS 102 - Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2009 What is your name?: There are three sections: I. True/False..............50 points; (25 questions, 2 points each) II. Multiple
More informationName: Username: I. 20. Section: II. p p p III. p p p p Total 100. CMSC 202 Section 06 Fall 2015
CMSC 202 Section 06 Fall 2015 Computer Science II Midterm Exam I Name: Username: Score Max Section: (check one) 07 - Sushant Athley, Tuesday 11:30am 08 - Aishwarya Bhide, Thursday 11:30am 09 - Phanindra
More informationLanguage Features. 1. The primitive types int, double, and boolean are part of the AP
Language Features 1. The primitive types int, double, and boolean are part of the AP short, long, byte, char, and float are not in the subset. In particular, students need not be aware that strings are
More informationCS 314 Exam 1 Spring 2017
Points off 1 2 3 4 5 6 Total off Net Score CS 314 Exam 1 Spring 2017 Your Name Your UTEID Instructions: 1. There are 6 questions on this test. 100 points available. Scores will be scaled to 175 points.
More informationMARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012
MARKING KEY The University of British Columbia MARKING KEY Computer Science 260 Midterm #2 Examination 12:30 noon, Thursday, March 15, 2012 Instructor: K. S. Booth Time: 70 minutes (one hour ten minutes)
More informationCS 102/107 - Introduction to Programming Midterm Exam #2 - Prof. Reed Spring 2011
CS 102/107 - Introduction to Programming Midterm Exam #2 - Prof. Reed Spring 2011 What is your name?: This test has the following sections: I. True/False... 60 points; (30 questions, 2 points each) II.
More informationpublic class Q1 { public int x; public static void main(string[] args) { Q1 a = new Q1(17); Q1 b = new Q1(39); public Q1(int x) { this.
CS 201, Fall 2013 Oct 2nd Exam 1 Name: Question 1. [5 points] What output is printed by the following program (which begins on the left and continues on the right)? public class Q1 { public int x; public
More informationCSEN 202: Introduction to Computer Programming Spring term Final Exam
Page 0 German University in Cairo May 28, 2016 Media Engineering and Technology Prof. Dr. Slim Abdennadher Dr. Wael Aboul Saadat CSEN 202: Introduction to Computer Programming Spring term 2015-2016 Final
More informationMidterm Exam 2 CS 455, Spring 2011
Name: USC loginid (e.g., ttrojan): Midterm Exam 2 CS 455, Spring 2011 March 31, 2011 There are 6 problems on the exam, with 50 points total available. There are 7 pages to the exam, including this one;
More informationAdvanced Object Oriented Programming EECS2030Z
Advanced Object Oriented Programming EECS2030Z 1 Academic Support Programs: Bethune having trouble with your FSC and LSE courses? consider using the Academic Support Programs at Bethune College PASS free,
More informationAdvanced Programming - CS239
Advanced Programming - CS239 Department of Computer Science LAB: EXPERIMENTING WITH SPECIALIZATION Getting Ready: Before going any further you should: 1. Make a directory on your N: drive for this lab.
More informationCS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language. Krste Asanović & Randy Katz
CS 61C: Great Ideas in Computer Architecture Lecture 2: Numbers & C Language Krste Asanović & Randy Katz http://inst.eecs.berkeley.edu/~cs61c Numbers wrap-up This is not on the exam! Break C Primer Administrivia,
More informationc) And last but not least, there are javadoc comments. See Weiss.
CSCI 151 Spring 2010 Java Bootcamp The following notes are meant to be a quick refresher on Java. It is not meant to be a means on its own to learn Java. For that you would need a lot more detail (for
More informationCS-140 Fall 2017 Test 1 Version Practice Practie for Sept. 27, Name:
CS-140 Fall 2017 Test 1 Version Practice Practie for Sept. 27, 2017 Name: 1. (10 points) For the following, Check T if the statement is true, the F if the statement is false. (a) T F : In mathematics,
More informationAbstract Classes and Interfaces
Abstract Classes and Interfaces Reading: Reges and Stepp: 9.5 9.6 CSC216: Programming Concepts Sarah Heckman 1 Abstract Classes A Java class that cannot be instantiated, but instead serves as a superclass
More information2. [20] Suppose we start declaring a Rectangle class as follows:
1. [8] Create declarations for each of the following. You do not need to provide any constructors or method definitions. (a) The instance variables of a class to hold information on a Minesweeper cell:
More informationIntroduction to Computer Science II (CSI 1101)
Introduction to Computer Science II (CSI 1101) Professor: M. Turcotte February 2002, duration: 75 minutes Identification Student name: last name: Section: Student number: initials: Signature: Instructions
More informationQuestions. Exams: no. Get by without own Mac? Why ios? ios vs Android restrictions. Selling in App store how hard to publish? Future of Objective-C?
Questions Exams: no Get by without own Mac? Why ios? ios vs Android restrictions Selling in App store how hard to publish? Future of Objective-C? Grading: Lab/homework: 40%, project: 40%, individual report:
More informationProgram Fundamentals
Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java
More informationArrays. CS10001: Programming & Data Structures. Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur
Arrays CS10001: Programming & Data Structures Pallab Dasgupta Dept. of Computer Sc. & Engg., Indian Institute of Technology Kharagpur 1 Array Many applications require multiple data items that have common
More informationAgenda. CS 61C: Great Ideas in Computer Architecture. Lecture 2: Numbers & C Language 8/29/17. Recap: Binary Number Conversion
CS 61C: Great Ideas in Computer Architecture Lecture 2: Numbers & C Language Krste Asanović & Randy Katz http://inst.eecs.berkeley.edu/~cs61c Numbers wrap-up This is not on the exam! Break C Primer Administrivia,
More informationComputer Science E-119 Fall Problem Set 1. Due before lecture on Wednesday, September 26
Due before lecture on Wednesday, September 26 Getting Started Before starting this assignment, make sure that you have completed Problem Set 0, which can be found on the assignments page of the course
More informationFinal Exam May 21, 2003
1.00 Introduction to Computers and Engineering Problem Solving Final Exam May 21, 2003 Name: Email Address: TA: Section: You have three hours to complete this exam. For coding questions, you do not need
More information