COMP 249 Midterm: COMP 249 Midterm Winter A 2015

75 views9 pages
31 Jan 2019
Department
Course
Professor

Document Summary

Write only on the provided sheets, however you may write on the back of each question sheet if you need extra space. Variant a (1 mark) consider the following code snippet. [01] generated by the following code. int[] a={3,1,3,3,7}; int[] b={4,1}; int[][] c={b,a}; System. out. println(a[a[3]-b[1]]); a[3-1]=a[1]=3 (1 mark) what will the output/exception be if the last line of question [01] is. System. out. println(c[a[2]][1]); c[2][1] = indexoutofbounds exception (1 mark) what will the output/exception be if the last line of question [01] is. System. out. println(c[b[1]][a[2]]); c[1][3]=a[3]=3 (1 mark) what will the output/exception be if the last line of question [01] is. [05] (2 marks) consider the following three commented lines: int[] a; int[] b=null; int[] c={}; 1 b/c a is uninitiated. (2 will return null pointer exception at runtime and 3 is ne) [06] (4 marks) consider the following method: public static void methoda (int a) { for(int i=1;i<=a;i++){ Write the equivalent method recursively. public static void methodb (int a) { if (a>1) methodb(a-1);

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers

Related Documents