Determine the answer to each of the following questions, using the available space for any necessary scratchwork.

Size: px
Start display at page:

Download "Determine the answer to each of the following questions, using the available space for any necessary scratchwork."

Transcription

1 AP Computer Science Jan 2016 Semester 1 Examination Part I: Multiple Choice Suggested time: 60 minutes. Mr. Alwin Tareen BNDS Number of questions: 18. Percent of total grade: 50. Determine the answer to each of the following questions, using the available space for any necessary scratchwork. Decide which is the best of the choices given, and fill in the corresponding bubble in the provided answer booklet. Assume that the classes in the Quick Reference have been imported where needed. Assume that variables and methods are declared within the context of an enclosing class. 1. Consider the following method: public static int mystery(int[] arr) int x = 0; for (int k = 0; k < arr.length; k = k + 2) x = x + arr[k]; return x; Assume that the array nums has been declared and initialized as follows: int[] nums = 3, 6, 1, 0, 1, 4, 2; What value will be returned as a result of the call mystery(nums)? (a) 5 (b) 6 (c) 7 (d) 10 (e) Consider the following method: public static String scramble(string word, int howfar) return word.substring(howfar+1, word.length()) + word.substring(0, howfar); What value is returned as a result of the call scramble("compiler", 3)? (a) "compiler" (b) "pilercom" (c) "ilercom" (d) "ilercomp" (e) No value is returned because an IndexOutOfBoundsException will be thrown.

2 APCS/S1E Page 2 of Consider the following code segment: int x = 7; int y = 3; if ((x < 10) && (y < 0)) System.out.println("Value is: " + x*y); else System.out.println("Value is: " + x/y); What is printed as a result of executing the code segment? (a) Value is: 21 (b) Value is: (c) Value is: 1 (d) Value is: 0 (e) Value is: 2 4. Consider the following method: public ArrayList<Integer> mystery(int n) ArrayList<Integer> seq = new ArrayList<Integer>(); for (int k = 1; k <= n; k++) seq.add(new Integer(k*k + 3)); return seq; Which of the following is printed as a result of executing the following statement? System.out.println(mystery(6)); (a) [3, 4, 7, 12, 19, 28] (b) [3, 4, 7, 12, 19, 28, 39] (c) [39, 28, 19, 12, 7, 4] (d) [39, 28, 19, 12, 7, 4, 3] (e) [4, 7, 12, 19, 28, 39] 5. Consider the following code segment. List<String> list = new ArrayList<String>(); list.add("p"); list.add("q"); list.add("r"); list.set(2, "s"); list.add(2, "T"); list.add("u"); What are the contents of list after executing the code segment? (a) [P,Q,R,s,T] (b) [P,Q,s,T,u] (c) [P,Q,T,s,u] (d) [P,T,Q,s,u] (e) [P,T,s,R,u]

3 APCS/S1E Page 3 of 15 Questions 6 and 7 refer to the following information: Consider the following partial class declaration: public class SomeClass private int mya; private int myb; private int myc; // Constructor(s) not shown public int geta() return mya; public void setb(int value) myb = value; 6. The following declaration appears in another class: SomeClass obj = new SomeClass(); Which of the following code segments will compile without error? (a) int x = obj.geta(); (b) int x; obj.geta(x); (c) int x = obj.mya; (d) int x = SomeClass.getA(); (e) int x = geta(obj); 7. Which of the following changes to SomeClass will allow other classes to access but not modify the value of myc? (a) Make myc public. (b) Include the method: public int getc() return myc; (c) Include the method: private int getc() return myc; (d) Include the method: public void getc(int x) x = myc; (e) Include the method: private void getc(int x) x = myc;

4 APCS/S1E Page 4 of Consider the following code segment: int[] arr = 1, 2, 3, 4, 5, 6, 7; for (int k = 3; k < arr.length-1; k++) arr[k] = arr[k+1]; Which of the following represents the contents of arr as a result of executing the code segment? (a) 1, 2, 3, 4, 5, 6, 7 (b) 1, 2, 3, 5, 6, 7 (c) 1, 2, 3, 5, 6, 7, 7 (d) 1, 2, 3, 5, 6, 7, 8 (e) 2, 3, 4, 5, 6, 7, 7 9. Consider the following code segment: int[] arr = 7, 2, 5, 3, 0, 10; for (int k = 0; k < arr.length-1; k++) if (arr[k] > arr[k+1]) System.out.print(k + " " + arr[k] + " "); What will be printed as a result of executing the code segment? (a) (b) (c) (d) (e) Consider the following method: public String mystery(string input) String output = ""; for (int k = 1; k < input.length(); k = k+2) output += input.substring(k, k+1); return output; What is returned as a result of the call mystery("computer")? (a) "computer" (b) "cmue" (c) "optr" (d) "ompute" (e) Nothing is returned because an IndexOutOfBoundsException is thrown.

5 APCS/S1E Page 5 of Assume that the array arr has been defined and initialized as follows. int[] arr = /* initial values for the array */ Which of the following will correctly print all of the odd integers contained in arr but none of the even integers contained in arr? (a) (b) (c) (d) (e) for (int x : arr) if (x%2 == 1) System.out.println(x); for (int k = 1; k < arr.length; k++) if (arr[k]%2 == 1) System.out.println(arr[k]); for (int x : arr) if (x%2 == 1) System.out.println(arr[x]); for (int k = 0; k < arr.length; k++) if (arr[k]%2 == 1) System.out.println(k); for (int x : arr) if (arr[x]%2 == 1) System.out.println(arr[x]); 12. Consider the following class declaration: public class Student private String myname; private int myage; public Student() /* implementation not shown */ public Student(String name, int age) /* implementation not shown */ // No other constructors Which of the following declarations will compile without error? I Student a = new Student(); II Student b = new Student("Juan", 15); III Student c = new Student("Juan", "15"); (a) I only (b) II only (c) I and II only (d) I and III only (e) I, II and III

6 APCS/S1E Page 6 of Consider the following class declaration: public class Person private String myname; private int myyearofbirth; public Person(String name, int yearofbirth) myname = name; myyearofbirth = yearofbirth; public String getname() return myname; public void setname(string name) myname = name; // There may be instance variables, constructors, and methods // that are not shown. Assume that the following declaration has been made. Person student = new Person("Thomas", 1995); Which of the following statements is the most appropriate for changing the name of student from "Thomas" to "Tom"? (a) student = new Person("Tom", 1995); (b) student.myname = "Tom"; (c) student.getname("tom"); (d) student.setname("tom"); (e) Person.setName("Tom"); 14. Assume that x and y are boolean variables and have been properly initialized. (x y) && x Which of the following always evaluates to the same value as the expression above? (a) x (b) y (c) x && y (d) x y (e) x!= y 15. Consider the following method, which is intended to return true if at least one of the three strings s1, s2 or s3 contains the substring "art". Otherwise, the method should return false. public static boolean containsart(string s1, String s2, String s3) String all = s1 + s2 + s3; return (all.indexof("art")!= -1);

7 APCS/S1E Page 7 of 15 Which of the following method calls demonstrates that the method does not work as intended? (a) containsart("rattrap", "similar", "today") (b) containsart("start", "article", "Bart") (c) containsart("harm", "chortle", "crowbar") (d) containsart("matriculate", "carat", "arbitrary") (e) containsart("darkroom", "cartoon", "articulate") Questions 16, 17 and 18 refer to the Time class declared below: public class Time private int myhrs; private int mymins; private int mysecs; public Time() /* implementation not shown */ public Time(int h, int m, int s) /* implementation not shown */ // Resets time to myhrs = h, mymins = m, mysecs = s. public void resettime(int h, int m, int s) /* implementation not shown */ // Advances time by one second. public void increment() /* implementation not shown */ // Returns true if this time equals t, false otherwise. public boolean equals(time t) /* implementation not shown */ // Returns true if this time is earlier than t, false otherwise. public boolean lessthan(time t) /* implementation not shown */ // Returns time as a String in the form hrs:mins:secs. public String tostring() /* implementation not shown */

8 APCS/S1E Page 8 of Which of the following is a false statement about the methods? (a) equals, lessthan, and tostring are all accessor methods. (b) increment is a mutator method. (c) Time() is the default constructor. (d) The Time class has three constructors. (e) There are no static methods in this class. 17. Which of the following represents correct implementation code for the constructor with parameters? (a) (b) myhrs = 0; mymins = 0; mysecs = 0; myhrs = h; mymins = m; mysecs = s; (c) resettime(myhrs, mymins, mysecs); (d) h = myhrs; m = mymins; s = mysecs; (e) Time = new Time(h, m, s); 18. A client class has a display method that writes the time represented by its parameter: // Outputs time t in the form hrs:mins:secs. public void display(time t) /* method body */ Which of the following are correct replacements for /* method body */? I Time T = new Time(h, m, s); System.out.println(T); II System.out.println(t.myHrs + ":" + t.mymins + ":" + t.mysecs); III System.out.println(t); (a) I only (b) II only (c) III only (d) II and III only (e) I, II and III

9 APCS/S1E Page 9 of 15 Part II: Free Response Suggested time: 60 minutes. Number of questions: 2. Percent of total grade: 50. SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Quick Reference have been imported where appropriate. Unless otherwise noted in the question, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied. In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined in that question. Writing significant amounts of code that can be replaced by a call to one of these methods may not receive full credit. MusicDownloads question(2013 AP CompSci Free Response) 1. A music Web site keeps track of downloaded music. For each download, the site uses a DownloadInfo object to store a song s title and the number of times it has been downloaded. A partial declaration for the DownloadInfo class is shown below. p u b l i c c l a s s DownloadInfo / C r e a t e s a new i n s t a n c e with the g i v e n unique t i t l e and s e t s the number o f t i m e s downloaded to t i t l e the unique t i t l e o f the downloaded song / p u b l i c DownloadInfo ( S t r i n g t i t l e ) / i m p l e m e n t a t i o n not shown / r e t u r n the t i t l e / p u b l i c S t r i n g g e t T i t l e ( ) / i m p l e m e n t a t i o n not shown / / I n c r e m e n t the number o f t i m e s downloaded by 1 / p u b l i c void incrementtimesdownloaded ( ) / i m p l e m e n t a t i o n not shown / // There may be i n s t a n c e v a r i a b l e s, c o n s t r u c t o r s, and methods // t h a t a r e not shown.

10 APCS/S1E Page 10 of 15 The list of downloaded information is stored in a MusicDownloads object. A partial declaration for the MusicDownloads class is shown below. p u b l i c c l a s s MusicDownloads / The l i s t o f downloaded i n f o r m a t i o n. Guaranteed not to be n u l l and not to c o n t a i n d u p l i c a t e t i t l e s. / p r i v a t e L i s t <DownloadInfo> d o w n l o a d L i s t ; / C r e a t e s the l i s t o f downloaded i n f o r m a t i o n. / p u b l i c MusicDownloads ( ) d o w n l o a d L i s t = new A r r a y L i s t <DownloadInfo >(); / Returns a r e f e r e n c e to the DownloadInfo o b j e c t with the r e q u e s t e d t i t l e i f i t e x i s t t i t l e the r e q u e s t e d t i t l r e t u r n a r e f e r e n c e to the DownloadInfo o b j e c t with the t i t l e t h a t matches the parameter t i t l e i f i t e x i s t s i n the l i s t ; n u l l o t h e r w i s e. P o s t c o n d i t i o n : no changes were made to d o w n l o a d L i s t. / p u b l i c DownloadInfo getdownloadinfo ( S t r i n g t i t l e ) / to be implemented i n p a r t ( a ) / / Updates d o w n l o a d L i s t with i n f o r m a t i o n from t i t l e t i t l e s a l i s t o f song t i t l e s P o s t c o n d i t i o n : t h e r e a r e no d u p l i c a t e t i t l e s i n d o w n l o a d L i s t. no e n t r i e s were removed from d o w n l o a d L i s t. a l l songs i n t i t l e s a r e r e p r e s e n t e d i n d o w n l o a d L i s t. f o r each e x i s t i n g e n t r y i n downloadlist, the download count i s i n c r e a s e d by the number o f t i m e s i t s t i t l e appeared i n t i t l e s. the o r d e r o f the e x i s t i n g e n t r i e s i n d o w n l o a d L i s t i s not changed. the f i r s t time an o b j e c t with a t i t l e from t i t l e s i s added to downloadlist, i t i s added to the end o f the l i s t. new e n t r i e s i n d o w n l o a d L i s t appear i n the same o r d e r i n which they f i r s t appear i n t i t l e s. f o r each new e n t r y i n downloadlist, the download count i s e q u a l to the number o f t i m e s i t s t i t l e appeared i n t i t l e s. / p u b l i c void updatedownloads ( L i s t <S t r i n g > t i t l e s ) / to be implemented i n p a r t ( b ) / // There may be i n s t a n c e v a r i a b l e s, c o n s t r u c t o r s, and methods t h a t // a r e not shown.

11 APCS/S1E Page 11 of 15 (a) (9 pts) Write the MusicDownloads method getdownloadinfo, which returns a reference to a DownloadInfo object if an object with a title that matches the parameter title exists in the downloadlist. If no song in downloadlist has a title that matches the parameter title, the method returns null. For example, suppose variable webmusica refers to an instance of MusicDownloads and that the table below represents the contents of downloadlist. The list contains three DownloadInfo objects. The object at position 0 has a title of Hey Jude and a download count of 5. The object at position 1 has a title of Soul Sister and a download count of 3. The object at position 2 has a title of Aqualung and a download count of 10. The call webmusica.getdownloadinfo("aqualung") returns a reference to the object in position 2 of the list. The call webmusica.getdownloadinfo("happy Birthday") returns null because there are no DownloadInfo objects with that title in the list. Do your work in the answer booklet.

12 APCS/S1E Page 12 of 15 (b) (9 pts) Write the MusicDownloads method updatedownloads, which takes a list of song titles as a parameter. For each title in the list, the method updates downloadlist, either by incrementing the download count if a DownloadInfo object with the same title exists, or by adding a new DownloadInfo object with that title and a download count of 1 to the end of the list. When a new DownloadInfo object is added to the end of the list, the order of the already existing entries in downloadlist remains unchanged. For example, suppose variable webmusicb refers to an instance of MusicDownloads and that the table below represents the contents of the instance variable downloadlist. Assume that the variable List<String> songtitles has been defined and contains the following entries. "Lights", "Aqualung", "Soul Sister", "Go Now", "Lights", "Soul Sister" The call webmusicb.updatedownloads(songtitles) results in the following downloadlist with incremented download counts for the objects with titles of Soul Sister and Aqualung. It also has a new DownloadInfo object with a title of Lights and a download count of 2, and another DownloadInfo object with a title of Go Now and a download count of 1. The order of the already existing entries remains unchanged. In writing your solution, you must use the getdownloadinfo method. Assume that getdownloadinfo works as specified, regardless of what you wrote for part (a). Do your work in the answer booklet.

13 APCS/S1E Page 13 of 15 Trail question(2010 AP CompSci Free Response) 2. A hiking trail has elevation markers posted at regular intervals along the trail. Elevation information about a trail can be stored in an array, where each element in the array represents the elevation at a marker. The elevation at the first marker will be stored at array index 0, the elevation at the second marker will be stored at array index 1, and so forth. Elevations between markers are ignored in this question. The graph below shows an example of trail elevations.

14 APCS/S1E Page 14 of 15 The declaration of the Trail class is shown below. You will write two unrelated methods of the Trail class. p u b l i c c l a s s T r a i l / R e p r e s e n t a t i o n o f the t r a i l. The number o f markers on the t r a i l i s markers. l e n g t h. / p r i v a t e i n t [ ] markers ; / Determines i f a t r a i l segment i s l e v e l. A t r a i l segment i s d e f i n e d by a s t a r t i n g marker, an ending marker, and a l l markers between t h o s e two markers. A t r a i l segment i s l e v e l i f i t has a d i f f e r e n c e between the max e l e v a t i o n and min e l e v a t i o n t h a t i s l e s s than or e q u a l to s t a r t the i n d e x o f the s t a r t i n g end the i n d e x o f the ending marker P r e c o n d i t i o n : 0 <= s t a r t < end <= markers. l e n g t h r e t u r n t r u e i f the d i f f e r e n c e between the maximum and minimum e l e v a t i o n on t h i s segment o f the t r a i l i s l e s s than or e q u a l to 10 meters ; f a l s e o t h e r w i s e. / p u b l i c boolean i s L e v e l T r a i l S e g m e n t ( i n t s t a r t, i n t end ) / to be implemented i n p a r t ( a ) / / Determines i f t h i s t r a i l i s r a t e d d i f f i c u l t. A t r a i l i s r a t e d by c o u n t i n g the number o f changes i n e l e v a t i o n t h a t a r e at l e a s t 30 meters ( up or down ) between two c o n s e c u t i v e markers. A t r a i l with 3 or more such changes i s r a t e d d i f f i c u l r e t u r n t r u e i f the t r a i l i s r a t e d d i f f i c u l t ; f a l s e o t h e r w i s e. / p u b l i c boolean i s D i f f i c u l t ( ) / to be implemented i n p a r t ( b ) / // There may be i n s t a n c e v a r i a b l e s, c o n s t r u c t o r s, and methods // t h a t a r e not shown.

15 APCS/S1E Page 15 of 15 (a) (9 pts) Write the Trail method isleveltrailsegment. A trail segment is defined by a starting marker, an ending marker, and all markers between those two markers. The parameters of the method are the index of the starting marker and the index of the ending marker. The method will return true if the difference between the maximum elevation and the minimum elevation in the trail segment is less than or equal to 10 meters. For the trail shown at the beginning of the question, the trail segment starting at marker 7 and ending at marker 10 has elevations ranging between 70 and 80 meters. Because the difference between 80 and 70 is equal to 10, the trail segment is considered level. The trail segment starting at marker 2 and ending at marker 12 has elevations ranging between 50 and 120 meters. Because the difference between 120 and 50 is greater than 10, this trail segment is not considered level. Do your work in the answer booklet. (b) (9 pts) Write the Trail method isdifficult. A trail is rated by counting the number of changes in elevation that are at least 30 meters (up or down) between two consecutive markers. A trail with 3 or more such changes is rated difficult. The following table shows trail elevation data and the elevation changes between consecutive trail markers. This trail is rated difficult because it has 4 changes in elevation that are 30 meters or more (between markers 0 and 1, between markers 1 and 2, between markers 3 and 4, and between markers 5 and 6). Do your work in the answer booklet.

COMPUTER SCIENCE A SECTION II

COMPUTER SCIENCE A SECTION II COMPUTER SCIENCE A SECTION II Time 1 hour and 4 minutes Number of questions 4 Percent of total score 0 Directions: SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Notes: Assume

More information

ArrayList<String> listname; //sets aside memory to store a reference //nothing has been constructed List<Integer> numberlistname;

ArrayList<String> listname; //sets aside memory to store a reference //nothing has been constructed List<Integer> numberlistname; Computer Science ArrayListList ArrayList listname; //sets aside memory to store a reference -OR- //nothing has been constructed List numberlistname; numberlistnamelist ArrayList

More information

AP Computer Science A 2013 Free-Response Questions

AP Computer Science A 2013 Free-Response Questions AP Computer Science A 2013 Free-Response Questions About the College Board The College Board is a mission-driven not-for-profit organization that connects students to college success and opportunity. Founded

More information

AP Computer Science A Directions for Administration

AP Computer Science A Directions for Administration Practice Exam The questions contained in this AP Computer Science A Practice Exam were written to the content specifications of AP Exams for this subject. Because this practice exam has never been given

More information

AP Computer Science Midterm Review Part 1

AP Computer Science Midterm Review Part 1 AP Computer Science Midterm Review Part 1 1. Consider the following method public void process(string s) s = s.substring(2, 3) + s.substring(1, 2) + s.substring(0, 1); What is printed as a result of executing

More information

12/13/11 APCS Monta Vista HS First Semester Final Exam Name

12/13/11 APCS Monta Vista HS First Semester Final Exam Name 12/13/11 APCS Monta Vista HS First Semester Final Exam Name 1. Consider the following code segment. String jolly = new String("Ho"); jolly.touppercase(); System.out.println(jolly + jolly.tolowercase());

More information

AP COMPUTER SCIENCE A 2010 GENERAL SCORING GUIDELINES

AP COMPUTER SCIENCE A 2010 GENERAL SCORING GUIDELINES AP COMPUTER SCIENCE A 2010 GENERAL SCORING GUIDELINES Apply the question-specific rubric first. To maintain scoring intent, a single error is generally accounted for only once per question thereby mitigating

More information

This exam is open book. Each question is worth 3 points.

This exam is open book. Each question is worth 3 points. This exam is open book. Each question is worth 3 points. Page 1 / 15 Page 2 / 15 Page 3 / 12 Page 4 / 18 Page 5 / 15 Page 6 / 9 Page 7 / 12 Page 8 / 6 Total / 100 (maximum is 102) 1. Are you in CS101 or

More information

Chapter 4 Defining Classes I

Chapter 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 information

AP CS Unit 7: Interfaces. Programs

AP CS Unit 7: Interfaces. Programs AP CS Unit 7: Interfaces. Programs You cannot use the less than () operators with objects; it won t compile because it doesn t always make sense to say that one object is less than

More information

Arrays and ArrayLists. David Greenstein Monta Vista High School

Arrays and ArrayLists. David Greenstein Monta Vista High School Arrays and ArrayLists David Greenstein Monta Vista High School Array An array is a block of consecutive memory locations that hold values of the same data type. Individual locations are called array s

More information

FORM 2 (Please put your name and form # on the scantron!!!!)

FORM 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 information

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade;

Sequence structure. The computer executes java statements one after the other in the order in which they are written. Total = total +grade; Control Statements Control Statements All programs could be written in terms of only one of three control structures: Sequence Structure Selection Structure Repetition Structure Sequence structure The

More information

AP COMPUTER SCIENCE A DIAGNOSTIC EXAM. Multiple Choice Section Time - 1 hour and 15 minutes Number of questions - 40 Percent of total grade - 50

AP COMPUTER SCIENCE A DIAGNOSTIC EXAM. Multiple Choice Section Time - 1 hour and 15 minutes Number of questions - 40 Percent of total grade - 50 AP COMPUTER SCIENCE A DIAGNOSTIC EXAM Multiple Choice Section Time - 1 hour and 15 minutes Number of questions - 40 Percent of total grade - 50 Directions: Determine the answer to each of the following

More information

Quiz 1 Unit 5A Arrays/Static Name

Quiz 1 Unit 5A Arrays/Static Name Quiz 1 Unit 5A Arrays/Static Name 1. What values are stored in arr after the following code segment has been executed? int[] arr = 1, 2, 3, 4, 5, 6, 7, 8; for (int k = 1; k

More information

CS 1331 Exam 1. Fall Failure to properly fill in the information on this page will result in a deduction of up to 5 points from your exam score.

CS 1331 Exam 1. Fall Failure to properly fill in the information on this page will result in a deduction of up to 5 points from your exam score. CS 1331 Exam 1 Fall 2016 Name (print clearly): GT account (gpburdell1, msmith3, etc): Section (e.g., B1): Signature: Failure to properly fill in the information on this page will result in a deduction

More information

CIT Special final examination

CIT Special final examination CIT 590-2016 Special final examination Name (please write your official name) PennID Number Note that your PennID number is the 8 digit bold number on your penn card. DO NOT START WRITING (aside from name

More information

Declarations and Access Control SCJP tips

Declarations and Access Control  SCJP tips Declarations and Access Control www.techfaq360.com SCJP tips Write code that declares, constructs, and initializes arrays of any base type using any of the permitted forms both for declaration and for

More information

Birkbeck (University of London) Software and Programming 1 In-class Test Mar Answer ALL Questions

Birkbeck (University of London) Software and Programming 1 In-class Test Mar Answer ALL Questions Birkbeck (University of London) Software and Programming 1 In-class Test 2.1 16 Mar 2017 Student Name Student Number Answer ALL Questions 1. What output is produced when the following Java program fragment

More information

COMPUTER SCIENCE A SECTION II

COMPUTER SCIENCE A SECTION II COMPUTER SCIENCE A SECTION II Time 1 hour and 45 minutes Number of questions 4 Percent of total score 50 Directions: SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Notes:

More information

Array Based Lists. Collections

Array Based Lists. Collections Array Based Lists Reading: RS Chapter 15 1 Collections Data structures stores elements in a manner that makes it easy for a client to work with the elements Specific collections are specialized for particular

More information

Defining Your Own Classes

Defining Your Own Classes Defining Your Own Classes In C, you are allowed to define a struct and then define variables of that struct. But Java allows you to define your own class. This means not only defining the data structure,

More information

Chief Reader Report on Student Responses:

Chief Reader Report on Student Responses: Chief Reader Report on Student Responses: 2017 AP Computer Science A Free-Response Questions Number of Students Scored 60,519 Number of Readers 308 Score Distribution Exam Score N %At Global Mean 3.15

More information

CSCI 136 Written Exam #0 Fundamentals of Computer Science II Spring 2015

CSCI 136 Written Exam #0 Fundamentals of Computer Science II Spring 2015 CSCI 136 Written Exam #0 Fundamentals of Computer Science II Spring 2015 Name: This exam consists of 6 problems on the following 7 pages. You may use your single-sided handwritten 8 ½ x 11 note sheet during

More information

CSE331 Winter 2014, Midterm Examination February 12, 2014

CSE331 Winter 2014, Midterm Examination February 12, 2014 CSE331 Winter 2014, Midterm Examination February 12, 2014 Please do not turn the page until 10:30. Rules: The exam is closed-book, closed-note, etc. Please stop promptly at 11:20. There are 100 points

More information

AP Computer Science A

AP Computer Science A 2017 AP Computer Science A Scoring Guidelines College Board, Advanced Placement Program, AP, AP Central, and the acorn logo are registered trademarks of the College Board. AP Central is the official online

More information

CS 1331 Exam 1 ANSWER KEY

CS 1331 Exam 1 ANSWER KEY CS 1331 Exam 1 Fall 2016 ANSWER KEY Failure to properly fill in the information on this page will result in a deduction of up to 5 points from your exam score. Signing signifies you are aware of and in

More information

University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ Test 2. Question Max Mark Internal External

University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ Test 2. Question Max Mark Internal External Name: Please fill in your Student Number and Name. Student Number : Student Number: University of Cape Town ~ Department of Computer Science Computer Science 1015F ~ 2009 Test 2 Question Max Mark Internal

More information

Fall CS 101: Test 2 Name UVA ID. Grading. Page 1 / 4. Page3 / 20. Page 4 / 13. Page 5 / 10. Page 6 / 26. Page 7 / 17.

Fall CS 101: Test 2 Name UVA  ID. Grading. Page 1 / 4. Page3 / 20. Page 4 / 13. Page 5 / 10. Page 6 / 26. Page 7 / 17. Grading Page 1 / 4 Page3 / 20 Page 4 / 13 Page 5 / 10 Page 6 / 26 Page 7 / 17 Page 8 / 10 Total / 100 1. (4 points) What is your course section? CS 101 CS 101E Pledged Page 1 of 8 Pledged The following

More information

int[] arr = new int[10]; Which of the following code segments correctly interchanges the value of arr[0] and arr[5]? A. arr[0] = 5; arr[5] = 0;

int[] arr = new int[10]; Which of the following code segments correctly interchanges the value of arr[0] and arr[5]? A. arr[0] = 5; arr[5] = 0; Name Computer Science Practice Exam #2 Multiple Choice 1. Assume that an array of integer values has been declared as follows and has been initialized. int[] arr = new int[10]; Which of the following code

More information

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class.

I pledge by honor that I will not discuss this exam with anyone until my instructor reviews the exam in the class. Name: Covers Chapters 1-3 50 mins CSCI 1301 Introduction to Programming Armstrong Atlantic State University Instructor: Dr. Y. Daniel Liang I pledge by honor that I will not discuss this exam with anyone

More information

Binghamton University. CS-140 Fall Problem Solving. Creating a class from scratch

Binghamton University. CS-140 Fall Problem Solving. Creating a class from scratch Problem Solving Creating a class from scratch 1 Recipe for Writing a Class 1. Write the class boilerplate stuff 2. Declare Fields 3. Write Creator(s) 4. Write accessor methods 5. Write mutator methods

More information

Goals for Today. CSE1030 Introduction to Computer Science II. CSE1030 Lecture #9. Review is-a versus has-a. Lecture #9 Inheritance I

Goals for Today. CSE1030 Introduction to Computer Science II. CSE1030 Lecture #9. Review is-a versus has-a. Lecture #9 Inheritance I CSE1030 Introduction to Computer Science II Lecture #9 Inheritance I Goals for Today Today we start discussing Inheritance (continued next lecture too) This is an important fundamental feature of Object

More information

CS 455 Final Exam Fall 2013 [Bono] December 12, 2013

CS 455 Final Exam Fall 2013 [Bono] December 12, 2013 Name: USC loginid (e.g., ttrojan): CS 455 Final Exam Fall 2013 [Bono] December 12, 2013 There are 9 problems on the exam, with 64 points total available. There are 7 pages to the exam, including this one;

More information

A First Object. We still have another problem. How can we actually make use of the class s data?

A First Object. We still have another problem. How can we actually make use of the class s data? A First Object // a very basic C++ object class Person public: Person(string name, int age); private: string name; int age; We still have another problem. How can we actually make use of the class s data?

More information

Computing Science 114 Solutions to Midterm Examination Tuesday October 19, In Questions 1 20, Circle EXACTLY ONE choice as the best answer

Computing Science 114 Solutions to Midterm Examination Tuesday October 19, In Questions 1 20, Circle EXACTLY ONE choice as the best answer Computing Science 114 Solutions to Midterm Examination Tuesday October 19, 2004 INSTRUCTOR: I E LEONARD TIME: 50 MINUTES In Questions 1 20, Circle EXACTLY ONE choice as the best answer 1 [2 pts] What company

More information

More Java Basics. class Vector { Object[] myarray;... //insert x in the array void insert(object x) {...} Then we can use Vector to hold any objects.

More Java Basics. class Vector { Object[] myarray;... //insert x in the array void insert(object x) {...} Then we can use Vector to hold any objects. More Java Basics 1. INHERITANCE AND DYNAMIC TYPE-CASTING Java performs automatic type conversion from a sub-type to a super-type. That is, if a method requires a parameter of type A, we can call the method

More information

Recommended Group Brainstorm (NO computers during this time)

Recommended Group Brainstorm (NO computers during this time) Recommended Group Brainstorm (NO computers during this time) Good programmers think before they begin coding. Part I of this assignment involves brainstorming with a group of peers with no computers to

More information

Flowcharts [15 points]

Flowcharts [15 points] Flowcharts [15 points] Draw a flowchart that receives some positive integer numbers and calculates and prints how many odd and how many even numbers it has received. The program stops, when it receives

More information

Homework Set 2- Class Design

Homework Set 2- Class Design 1 Homework Set 2- Class Design By the end of the lesson students should be able to: a. Write the Java code define a class, its data members, and its constructors. b. Write a tostring() method for a class.

More information

I. True/False: (2 points each)

I. True/False: (2 points each) CS 102 - Introduction to Programming Midterm Exam #2 - Prof. Reed Spring 2008 What is your name?: (2 points) There are three sections: I. True/False..............54 points; (27 questions, 2 points each)

More information

CS 455 Midterm 2 Fall 2017 [Bono] Nov. 7, 2017

CS 455 Midterm 2 Fall 2017 [Bono] Nov. 7, 2017 Name: USC NetID (e.g., ttrojan): CS 455 Midterm 2 Fall 2017 [Bono] Nov. 7, 2017 There are 6 problems on the exam, with 62 points total available. There are 10 pages to the exam (5 pages double-sided),

More information

SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177. Programming

SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177. Programming s SCHOOL OF COMPUTING, ENGINEERING AND MATHEMATICS SEMESTER 1 EXAMINATIONS 2015/2016 CI101 / CI177 Programming Time allowed: THREE hours: Answer: ALL questions Items permitted: Items supplied: There is

More information

Object-oriented Programming and Software Engineering CITS1001. Multiple-choice Mid-semester Test

Object-oriented Programming and Software Engineering CITS1001. Multiple-choice Mid-semester Test Object-oriented Programming and Software Engineering CITS1001 Multiple-choice Mid-semester Test Semester 1, 2015 Mark your solutions on the provided answer page, by filling in the appropriate circles.

More information

More about inheritance

More about inheritance Main concepts to be covered More about inheritance Exploring polymorphism method polymorphism static and dynamic type overriding dynamic method lookup protected access 4.1 The inheritance hierarchy Conflicting

More information

Table of Contents Date(s) Title/Topic Page #s. Chapter 4: Writing Classes 4.1 Objects Revisited

Table of Contents Date(s) Title/Topic Page #s. Chapter 4: Writing Classes 4.1 Objects Revisited Table of Contents Date(s) Title/Topic Page #s 11/6 Chapter 3 Reflection/Corrections 56 Chapter 4: Writing Classes 4.1 Objects Revisited 57 58-59 look over your Ch 3 Tests and write down comments/ reflections/corrections

More information

APCS Semester #1 Final Exam Practice Problems

APCS Semester #1 Final Exam Practice Problems Name: Date: Per: AP Computer Science, Mr. Ferraro APCS Semester #1 Final Exam Practice Problems The problems here are to get you thinking about topics we ve visited thus far in preparation for the semester

More information

Prelim 1 SOLUTION. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants. Recursion OO Short answer

Prelim 1 SOLUTION. CS 2110, September 29, 2016, 7:30 PM Total Question Name Loop invariants. Recursion OO Short answer Prelim 1 SOLUTION CS 2110, September 29, 2016, 7:30 PM 0 1 2 3 4 5 Total Question Name Loop invariants Recursion OO Short answer Exception handling Max 1 15 15 25 34 10 100 Score Grader 0. Name (1 point)

More information

Name CIS 201 Midterm II: Chapters 1-8

Name CIS 201 Midterm II: Chapters 1-8 Name CIS 201 Midterm II: Chapters 1-8 December 15, 2010 Directions: This is a closed book, closed notes midterm. Place your answers in the space provided. The point value for each question is indicated.

More information

CS 200 Objects and ArrayList Jim Williams, PhD

CS 200 Objects and ArrayList Jim Williams, PhD CS 200 Objects and ArrayList Jim Williams, PhD This Week 1. Academic Integrity 2. BP1: Milestone 2 due this week 3. Team Lab: Multi-Dimensional Arrays a. Bring paper and pencil to draw diagrams. b. Code

More information

AP CS Unit 7: Interfaces Exercises Assume all code compiles unless otherwise suggested.

AP CS Unit 7: Interfaces Exercises Assume all code compiles unless otherwise suggested. AP CS Unit 7: Interfaces Exercises Assume all code compiles unless otherwise suggested. 1. The Nose class... b) will not compile because the m1 method parameter should be named n, not x. 2. The Ears class...

More information

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide

AP Computer Science Chapter 10 Implementing and Using Classes Study Guide AP Computer Science Chapter 10 Implementing and Using Classes Study Guide 1. A class that uses a given class X is called a client of X. 2. Private features of a class can be directly accessed only within

More information

// constructor: takes a String as parameter and creates a public Cat (String x) { name = x; age = 0; lives = 9; // cats start out with 9 lives }

// constructor: takes a String as parameter and creates a public Cat (String x) { name = x; age = 0; lives = 9; // cats start out with 9 lives } Quiz 6 Name: 1. Suppose you have a class Cat defined as shown below. Fill in the code for the indicated methods, following guidelines given through comments. public class Cat // instance variables String

More information

CS162 Computer Science I Fall 2018 Practice Exam 1 DRAFT (9 Oct.)

CS162 Computer Science I Fall 2018 Practice Exam 1 DRAFT (9 Oct.) Name: CS162 Computer Science I Fall 2018 Practice Exam 1 DRAFT (9 Oct.) The real test will look much like this one, but it will be shorter. I suggest taking this practice test under real conditions (closed

More information

AP Computer Science A

AP Computer Science A 2017 AP Computer Science A Sample Student Responses and Scoring Commentary Inside: RR Free Response Question 1 RR Scoring Guideline RR Student Samples RR Scoring Commentary 2017 The College Board. College

More information

CS 101 Exam 2 Spring Id Name

CS 101 Exam 2 Spring Id Name CS 101 Exam 2 Spring 2005 Email Id Name This 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,

More information

INTRODUCTION TO SOFTWARE SYSTEMS (COMP1110/COMP1140/COMP1510/COMP6710)

INTRODUCTION TO SOFTWARE SYSTEMS (COMP1110/COMP1140/COMP1510/COMP6710) Important notice: This document is a sample exam. The final exam will differ from this exam in numerous ways. The purpose of this sample exam is to provide students with access to an exam written in a

More information

public static boolean isoutside(int min, int max, int value)

public 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 information

Arrays. https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html

Arrays. https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html 1 Arrays Arrays in Java an array is a container object that holds a fixed number of values of a single type the length of an array is established when the array is created 2 https://docs.oracle.com/javase/tutorial/java/nutsandbolts/arrays.html

More information

3. Convert 2E from hexadecimal to decimal. 4. Convert from binary to hexadecimal

3. 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 information

1st Semester Examinations CITS1001 3

1st Semester Examinations CITS1001 3 1st Semester Examinations CITS1001 3 Question 1 (10 marks) Write a Java class Student with three fields: name, mark and maxscore representing a student who has scored mark out of maxscore. The class has

More information

(a) Assume that in a certain country, tax is payable at the following rates:

(a) Assume that in a certain country, tax is payable at the following rates: 3 1. (Total = 12 marks) (a) Assume that in a certain country, tax is payable at the following rates: 15% on your first $50000 income 25% on any amount over $50000 Write a method that takes in an annual

More information

CSCI 212 Practice Final Exam Summer Instructor: Krishna Mahavadi

CSCI 212 Practice Final Exam Summer Instructor: Krishna Mahavadi QUEENS COLLEGE Department of Computer Science CSCI 212 Practice Final Exam Summer 2017 08.13.17 Instructor: Krishna Mahavadi August 13, 2017 Problem 1 (10 points) (a): Create an interface MessageEncoder.

More information

Assignment3 CS206 Intro to Data Structures Fall Part 1 (50 pts) due: October 13, :59pm Part 2 (150 pts) due: October 20, :59pm

Assignment3 CS206 Intro to Data Structures Fall Part 1 (50 pts) due: October 13, :59pm Part 2 (150 pts) due: October 20, :59pm Part 1 (50 pts) due: October 13, 2013 11:59pm Part 2 (150 pts) due: October 20, 2013 11:59pm Important Notes This assignment is to be done on your own. If you need help, see the instructor or TA. Please

More information

Java 1996 AP Computer Science Question 3

Java 1996 AP Computer Science Question 3 Java 1996 AP Computer Science Question 3 http://www.cs.duke.edu/csed/ap/exams/1996/ab3.html 1 of 2 7/8/2003 5:07 PM Java 1996 AP Computer Science Question 3 Assume that binary trees are implemented using

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 03: Creating Classes MOUNA KACEM mouna@cs.wisc.edu Spring 2019 Creating Classes 2 Constructors and Object Initialization Static versus non-static fields/methods Encapsulation

More information

Final Examination Semester 3 / Year 2010

Final Examination Semester 3 / Year 2010 Southern College Kolej Selatan 南方学院 Final Examination Semester 3 / Year 2010 COURSE : OBJECT-ORIENTED PROGRAMMING COURSE CODE : PROG 2013 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM

More information

If a class implements an interface and then fails to implement any methods in that interface, then the class must be declared abstract.

If a class implements an interface and then fails to implement any methods in that interface, then the class must be declared abstract. 12/18/12 APCS Monta Vista HS First Semester Final Exam DO NOT WRITE ON THIS EXAM 1. What is the value of product after the following code segment is executed? (A) 2 (B) 3 (C) 4 (D) 5 (E) 9 int [] factors

More information

CSE 331 Midterm Exam Sample Solution 2/18/15

CSE 331 Midterm Exam Sample Solution 2/18/15 Question 1. (10 points) (Forward reasoning) Using forward reasoning, write an assertion in each blank space indicating what is known about the program state at that point, given the precondition and the

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 03: Creating Classes MOUNA KACEM mouna@cs.wisc.edu Spring 2018 Creating Classes 2 Constructors and Object Initialization Static versus non-static fields/methods Encapsulation

More information

Prelim 1. CS 2110, October 1, 2015, 5:30 PM Total Question Name True Short Testing Strings Recursion

Prelim 1. CS 2110, October 1, 2015, 5:30 PM Total Question Name True Short Testing Strings Recursion Prelim 1 CS 2110, October 1, 2015, 5:30 PM 0 1 2 3 4 5 Total Question Name True Short Testing Strings Recursion False Answer Max 1 20 36 16 15 12 100 Score Grader The exam is closed book and closed notes.

More information

AP CS Unit 7: Interfaces Exercises 1. Select the TRUE statement(s).

AP CS Unit 7: Interfaces Exercises 1. Select the TRUE statement(s). AP CS Unit 7: Interfaces Exercises 1. Select the TRUE statement(s). a) This code will not compile because a method cannot specify an interface as a parameter. public class Testing { public static void

More information

public static void negate2(list<integer> t)

public static void negate2(list<integer> t) 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 information

Introduction to Computer Science Midterm 3 Fall, Points

Introduction to Computer Science Midterm 3 Fall, Points Introduction to Computer Science Fall, 2001 100 Points Notes 1. Tear off this sheet and use it to keep your answers covered at all times. 2. Turn the exam over and write your name next to the staple. Do

More information

Computer Science E-119 Fall Problem Set 1. Due before lecture on Wednesday, September 26

Computer 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 information

Practice Midterm 1. Problem Points Score TOTAL 50

Practice 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 information

1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8

1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8 Epic Test Review 1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4 Write a line of code that outputs the phase Hello World to the console without creating a new line character. System.out.print(

More information

CPSC 233: Assignment 4 (Due March 26 at 4 PM)

CPSC 233: Assignment 4 (Due March 26 at 4 PM) CPSC 233: Assignment 4 (Due March 26 at 4 PM) New learning concepts: Problem solving using object-oriented programming. Aside from main() you cannot implement other static methods. Also you should not

More information

CS100J Prelim 1 22 February 2007

CS100J Prelim 1 22 February 2007 NAME Cornell Net id 1/5 CS100J Prelim 1 22 February 2007 This 90-minute exam has 6 questions (numbered 0..5) worth a total of 100 points. Scan the whole test before starting. Budget your time wisely. Use

More information

One of Mike s early tests cases involved the following code, which produced the error message about something being really wrong:

One of Mike s early tests cases involved the following code, which produced the error message about something being really wrong: Problem 1 (3 points) While working on his solution to project 2, Mike Clancy encountered an interesting bug. His program includes a LineNumber class that supplies, among other methods, a constructor that

More information

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014

Lesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014 Lesson 10A OOP Fundamentals By John B. Owen All rights reserved 2011, revised 2014 Table of Contents Objectives Definition Pointers vs containers Object vs primitives Constructors Methods Object class

More information

CS/ENGRD 2110 SPRING Lecture 5: Local vars; Inside-out rule; constructors

CS/ENGRD 2110 SPRING Lecture 5: Local vars; Inside-out rule; constructors 1 CS/ENGRD 2110 SPRING 2017 Lecture 5: Local vars; Inside-out rule; constructors http://courses.cs.cornell.edu/cs2110 Announcements 2 1. Writing tests to check that the code works when the precondition

More information

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS PAUL L. BAILEY Abstract. This documents amalgamates various descriptions found on the internet, mostly from Oracle or Wikipedia. Very little of this

More information

CS 101 Fall 2006 Midterm 3 Name: ID:

CS 101 Fall 2006 Midterm 3 Name:  ID: You only need to write your name and e-mail ID on the first page. This exam is CLOSED text book, closed-notes, closed-calculator, closed-neighbor, etc. Questions are worth different amounts, so be sure

More information

CS 251 Intermediate Programming Methods and Classes

CS 251 Intermediate Programming Methods and Classes CS 251 Intermediate Programming Methods and Classes Brooke Chenoweth University of New Mexico Fall 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

More information

CS 251 Intermediate Programming Methods and More

CS 251 Intermediate Programming Methods and More CS 251 Intermediate Programming Methods and More Brooke Chenoweth University of New Mexico Spring 2018 Methods An operation that can be performed on an object Has return type and parameters Method with

More information

Multiple Choice Questions Consider the following method and code segment.

Multiple Choice Questions Consider the following method and code segment. Multiple Choice Questions 01-08. 01. Consider the following method and code segment. public static double jack(double seed) seed = seed + Math.PI; seed = Math.sqrt(seed); seed = seed - (int) seed; return

More information

Assignment 1 due Monday at 11:59pm

Assignment 1 due Monday at 11:59pm Assignment 1 due Monday at 11:59pm The heart of Object-Oriented Programming (Now it gets interesting!) Reading for next lecture is Ch. 7 Focus on 7.1, 7.2, and 7.6 Read the rest of Ch. 7 for class after

More information

ITI 1120 Lab #9. Slides by: Diana Inkpen, Alan Williams, Daniel Amyot Some original material by Romelia Plesa

ITI 1120 Lab #9. Slides by: Diana Inkpen, Alan Williams, Daniel Amyot Some original material by Romelia Plesa ITI 1120 Lab #9 Slides by: Diana Inkpen, Alan Williams, Daniel Amyot Some original material by Romelia Plesa 1 Objectives Review fundamental concepts Example: the Time class Exercises Modify the Time class

More information

Practice Questions for Final Exam: Advanced Java Concepts + Additional Questions from Earlier Parts of the Course

Practice Questions for Final Exam: Advanced Java Concepts + Additional Questions from Earlier Parts of the Course : Advanced Java Concepts + Additional Questions from Earlier Parts of the Course 1. Given the following hierarchy: class Alpha {... class Beta extends Alpha {... class Gamma extends Beta {... In what order

More information

if (x == 0); System.out.println( x=0 ); if (x = 0) System.out.println( x=0 );

if (x == 0); System.out.println( x=0 ); if (x = 0) System.out.println( x=0 ); Sample Final Exam 1. Evaluate each of the following expressions and show the result and data type of each: Expression Value Data Type 14 % 5 1 / 2 + 1 / 3 + 1 / 4 4.0 / 2.0 Math.pow(2.0, 3.0) (double)(2

More information

What we will do today Explain and look at examples of. Programs that examine data. Data types. Topic 4. variables. expressions. assignment statements

What we will do today Explain and look at examples of. Programs that examine data. Data types. Topic 4. variables. expressions. assignment statements Topic 4 Variables Once a programmer has understood the use of variables, he has understood the essence of programming -Edsger Dijkstra What we will do today Explain and look at examples of primitive data

More information

Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers-Weeda Sjaak Smetsers Ana Tanase

Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers-Weeda Sjaak Smetsers Ana Tanase Algorithmic Thinking and Structured Programming (in Greenfoot) Teachers: Renske Smetsers-Weeda Sjaak Smetsers Ana Tanase Today s Lesson plan (10) Retrospective Previous lesson Theory: Nested if.. then..

More information

CSE 331 Midterm Exam 11/9/15 Sample Solution

CSE 331 Midterm Exam 11/9/15 Sample Solution Remember: For all of the questions involving proofs, assertions, invariants, and so forth, you should assume that all numeric quantities are unbounded integers (i.e., overflow can not happen) and that

More information

Introduction to Computer Science II (CSI 1101)

Introduction 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 information

CSC207 Quiz 1 Solutions Monday 6 February 2017, 12:15 PM. 1. (A) (B) (C) (D) (E) 7. Nothing, does not run true false

CSC207 Quiz 1 Solutions Monday 6 February 2017, 12:15 PM. 1. (A) (B) (C) (D) (E) 7. Nothing, does not run true false CSC207 Quiz 1 Solutions Monday 6 February 2017, 12:15 PM Student Number: Circle the lecture section in which you are enrolled L0101 (WF12) L0201 (WF1) L5101 (W6) Please indicate your answers in the table

More information

1B1b Classes in Java Part I

1B1b Classes in Java Part I 1B1b Classes in Java Part I Agenda Defining simple classes. Instance variables and methods. Objects. Object references. 1 2 Reading You should be reading: Part I chapters 6,9,10 And browsing: Part IV chapter

More information

Practice Midterm Examination

Practice Midterm Examination Steve Cooper Handout #28 CS106A May 1, 2013 Practice Midterm Examination Midterm Time: Tuesday, May 7, 7:00P.M. 9:00P.M. Portions of this handout by Eric Roberts and Patrick Young This handout is intended

More information

5. PLEASE TAKE HOME the question bundle, but turn in 2 paper sheets: The scantron AND the paper where you wrote your programming question solution!

5. PLEASE TAKE HOME the question bundle, but turn in 2 paper sheets: The scantron AND the paper where you wrote your programming question solution! FINAL EXAM Introduction to Computer Science UA-CCI- ICSI 201--Fall13 This is a closed book and note examination, except for one 8 1/2 x 11 inch paper sheet of notes, both sides. There is no interpersonal

More information