22 Pages

2007SSTestAnswers

Course: COMPSCI 101, Summer 2012
School: University of Auckland
Rating:
 
 
 
 
 

Word Count: 1851

Document Preview

101 THE CompSci UNIVERSITY OF AUCKLAND SUMMER SEMESTER, 2007 Campus: City COMPUTER SCIENCE TEST Principles of Programming (Time allowed: 75 MINUTES) NOTE: Attempt ALL questions Write your answers in the space provided There is space at the back for answers that overflow the allotted space No calculators are permitted Surname: Forenames: Student ID number: Login name: CONTINUED Question/Answer Sheet -...

Register Now

Unformatted Document Excerpt

Coursehero >> Other International >> University of Auckland >> COMPSCI 101

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
101 THE CompSci UNIVERSITY OF AUCKLAND SUMMER SEMESTER, 2007 Campus: City COMPUTER SCIENCE TEST Principles of Programming (Time allowed: 75 MINUTES) NOTE: Attempt ALL questions Write your answers in the space provided There is space at the back for answers that overflow the allotted space No calculators are permitted Surname: Forenames: Student ID number: Login name: CONTINUED Question/Answer Sheet - Page 2 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... CompSci 101 Test Results Question Marks Out of Question 1 28 Question 2 6 Question 3 10 Question 4 5 Question 5 14 Question 6 6 Question 7 6 TOTAL 75 CONTINUED Question/Answer Sheet - Page 3 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... Question 1 (28 marks) a) What output is produced by the following code? System.out.println(1 + 2 + "3" + 4 + 5); 3345 (2 marks) b) What output is produced by the following code? System.out.println("\"" + "\\nn"); "\nn (2 marks) c) Consider the following boolean expression: (a && b) || (!a) What values would need to be stored in the boolean variables a and b so that this expression evaluates to false? a = true; b = false; (2 marks) CONTINUED Question/Answer Sheet - Page 4 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... d) What output is produced by the following code? int int int int a b c d = = = = 1; 2; 3; Math.max(Math.min(a, b), Math.min(b, c)); System.out.println(d); 2 (2 marks) e) What output is produced by the following code? System.out.println((1 + 2 * 3) / 4 + 5); 6 (2 marks) f) What output is produced by the following code? int x = 100; int y = x; x = 10; System.out.print(y); String s = "10"; String t = s.substring(0,1); System.out.println(s + t); 100101 (2 marks) CONTINUED Question/Answer Sheet - Page 5 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... g) What output is produced by the following code? int a = 0; int b = 7; a = b; b = a; System.out.println(a + b); 14 (2 marks) h) What output is produced by the following code? int[] nums = { 1, 2, 3, 4, 5 }; nums[0] = nums[3]; nums[1] = nums[2] + nums[4]; nums[2] = nums.length; nums[ nums[1] - nums[2] ] = 10; System.out.print(nums[0] System.out.print(nums[1] System.out.print(nums[2] System.out.print(nums[3] System.out.print(nums[4] + + + + + " " " " " "); "); "); "); "); 4 8 5 10 5 (2 marks) CONTINUED Question/Answer Sheet - Page 6 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... i) The printOutput() method is called in the following way: printOutput(3.5, 'H', "Hello"); Complete the method header for the printOutput() method (i.e. complete the first line of the method definition). private void printOutput(double a, char b, String c) { System.out.println(a + " " + b + " " + c); } (2 marks) j) The getLetter() method is called in the following way: char c = getLetter("Test", 3); Complete the method header for the getLetter() method (i.e. complete the first line of the method definition). private char getLetter(String a, int b) { return a.charAt(b); } (2 marks) k) What is the number of characters in the String returned by the method call: s.substring(4, 10) 6 (2 marks) CONTINUED Question/Answer Sheet - Page 7 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... l) Consider the following class stored in a file called MyApplication.java: public class MyApplication { public static void main(String[] args) { MyProgram p = new MyProgram(); p.start(); } } Also consider the following class stored in a file called MyProgram.java: public class MyProgram { public void start() { System.out.println("Hello World"); } } If MyApplication.java and MyProgram.java are both stored in the current directory, give the correct DOS commands required to compile and run this program so that the output "Hello World" is produced: javac MyProgram.java javac MyApplication.java java MyApplication or javac *.java java MyApplication or javac MyApplication.java java MyApplication (2 marks) CONTINUED Question/Answer Sheet - Page 8 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... m) What output is produced by the following code? String a = "c"; String b = "compsci"; String c = b.substring(0,1); System.out.println(a + " " + c + " " + (a == c)); c c false (2 marks) n) What output is produced by the following code? int[] a = {7, 6, 2, 0, 1}; int[] b; b = a; b[3] = 100; System.out.println(a[3]); 100 (2 marks) CONTINUED Question/Answer Sheet - Page 9 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... Question 2 (6 marks) What is the output of the following program: public class MyProgram { public void start() { int a = 10; int b = 20; if (a < b) { System.out.println("one"); } if (a == b) { System.out.println("two"); } if ((a + b) > 0) { System.out.println("three"); } if (a < b) { System.out.println("four"); } else if (a == b) { System.out.println("five"); } else if ((a + b) > 0) { System.out.println("six"); } else { System.out.println("seven"); } } } one three four (6 marks) CONTINUED Question/Answer Sheet - Page 10 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... Question 3 (10 marks) Consider the following start() method: public void start() { int c1 = (int)(Math.random()*13) + 1; int c2 = (int)(Math.random()*13) + 1; if (isBlackjack(c1, c2)) { System.out.println("A blackjack!"); } } The start() method deals two cards, storing their numeric values in the variables c1 and c2. It then calls the isBlackjack() method to test whether the two cards form a blackjack, and prints out "A blackjack!" if they do. To answer this question, you need to define the following TWO methods: ... isBlackjack(...) ... cardValue(int cardNumber) The cardValue() method is passed the number of a card as a parameter. The number 1 represents an Ace, numbers 11, 12 and 13 represent the Jack, Queen and King picture cards respectively, and any number between 2 and 10 represents a card with that face value. The method should then calculate and return the value that the card represents in a game of blackjack. The value of an Ace is 11, the value of any picture card is 10, and the values of all other cards are their face values. The isBlackjack() method is passed the two cards that have been dealt, and must return true if those cards form a blackjack, and false if they do not (a blackjack is when the sum of the card values of the two cards equals 21). This method must call the cardValue() method to obtain the value of each card. You will need to define appropriate return types for both methods, and appropriate parameters for the isBlackjack() method. CONTINUED Question/Answer Sheet - Page 11 - CompSci 101 SS C SURNAME: ...................................................... ........................................................... isBlackjack( ){ private FORENAMES: boolean isBlackjack(int c1, int c2) { int total = cardValue(c1) + cardValue(c2); return (total == 21); } } (5 marks) cardValue( int cardNumber ) { private int cardValue(int cardNumber) { if (cardNumber == 1) return 11; if (cardNumber > 10) return 10; return cardNumber; } } (5 marks) CONTINUED Question/Answer Sheet - Page 12 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... Question 4 (5 marks) The formula for converting a temperature from Fahrenheit to Celsius is given below: Consider the following program which asks the user to enter a temperature in Fahrenheit, and prints out the result in Celsius: public class MyProgram { public void start() { System.out.println("Temperature conversion"); System.out.print("Enter temperature (F): "); int input = Keyboard.readInput(); int input = Integer.parseInt(Keyboard.readInput()); int result = convertFahrenheitToCelsius(input); System.out.println("Celsius = " + result); } private int convertFahrenheitToCelsius(int degF) { int degC = (int)((5/9)*(degF - 32)); int degC = (int)((5.0/9)*(degF - 32)); return degC; } } (5 marks) There is exactly one syntax error and one logic error in the above code. The syntax error will be detected by the compiler, and in response the compiler will generate the following error message: "incompatible types" The logic error will not be detected by the compiler but will cause the output to be incorrect. Circle the line of code that contains the syntax error, and circle the line of code that contains the logic error and provide corrections for both of these errors underneath the incorrect lines. CONTINUED Question/Answer Sheet - Page 13 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... Question 5 (14 marks) The following class defines a playing card. public class Card { private int cardNumber; private String suit; public Card(int num, String suit) { cardNumber = num; this.suit = suit; } public void setSuit(String suit) { this.suit = suit; } public String getSuit() { return suit; } public void setCardNumber(int num) { cardNumber = num; } public int getCardNumber() { return cardNumber; } public boolean isAPictureCard() { if(cardNumber > 10 && cardNumber < 14) { return true; } return false; } public String toString() { String cardDesc = "Playing card: "; if( cardNumber == 11) { cardDesc = cardDesc + "J"; } else if( cardNumber == 12) { cardDesc = cardDesc + "Q"; } else if( cardNumber == 13) { cardDesc = cardDesc + "K"; } else if( cardNumber == 1) { cardDesc = cardDesc + "A"; } else { cardDesc = cardDesc + cardNumber; } cardDesc = cardDesc + " of " + suit; return cardDesc; } } CONTINUED Question/Answer Sheet - Page 14 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... a) Two objects of type Card are created as follows: Card card1 = new Card(12, "Hearts"); Card card2 = new Card(1, "Spades"); Complete the diagram below illustrating the values that are stored in the instance variables for each of these objects. You should write very clearly on the diagram, as you are required to change the diagram when you complete part (b) of this question. "Hearts" suit card1 cardNumber 12 4 "Spades" suit "Clubs" card2 cardNumber 1 (6 marks) CONTINUED Question/Answer Sheet - Page 15 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... b) Given the two Card objects created and initialised as in the diagram on the previous page, what would be the output after the following statements are executed? Note: you MUST also mark any changes to any instance variables clearly on the diagram on the previous page. card2.setSuit("Clubs"); card1.setCardNumber(4); if (card1.isAPictureCard()) { System.out.println("1. Picture card"); } else { System.out.println("2. Not a picture card"); } System.out.println("3. " + card2.getSuit()); System.out.println("4. " + card1.toString()); System.out.println("5. " + card2.toString()); The output would be: 2. 3. 4. 5. Not a picture card Clubs Playing card: 4 of Hearts Playing card: A of Clubs (8 marks) CONTINUED Question/Answer Sheet - Page 16 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... Question 6 (6 marks) What is the output of the following program: public class MyProgram { public void start() { int a = 10; methodOne(a); System.out.println(a); } private void methodOne(int a) { a = a + 1; a = methodTwo(a); System.out.println(a); } private int methodTwo(int x) { System.out.println(x); return x + x; } } Show the output here: 11 22 10 (6 marks) CONTINUED Question/Answer Sheet - Page 17 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... Working for Question 6: Diagrams of the method calls are not required but partial credit may be given for working if the output is incorrect. start() a: 10 methodOne(10) a: 10 11 22 22 methodTwo(11) x 11 CONTINUED Question/Answer Sheet - Page 18 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... Question 7 (6 marks) What is the output of the following program: public class MyProgram { public void start() { int[] x = {1, 2, 3, 4, 5, 6}; int[] y = process(x); for (int i = 0; i < y.length; i++) { System.out.print(y[i] + " "); } } private int[] process(int[] a) { int[] result = new int[a.length / 2]; for (int i = 0; i < result.length; i++) { result[i] = a[i*2] + 1; } return result; } } 246 (6 marks) CONTINUED Question/Answer Sheet - Page 19 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... OVERFLOW PAGE (If you have used this page, please indicate clearly under the relevant question that you have overflowed to this page) CONTINUED Question/Answer Sheet - Page 20 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... ROUGH WORKING (WILL NOT BE MARKED) (You may detach this page from the answer booklet and use it for rough working) CONTINUED Question/Answer Sheet - Page 21 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... ROUGH WORKING (WILL NOT BE MARKED) (You may detach this page from the answer booklet and use it for rough working) Question/Answer Sheet - Page 22 - CompSci 101 SS C SURNAME: ...................................................... FORENAMES: ........................................................... APPENDIX: Useful methods and variables: String public public public public public public int indexOf(char c) int indexOf(String string) char charAt(int index) String substring(int beginIndex, int endIndex) int length() boolean equals(String comparison) StringTokenizer public boolean hasMoreTokens() public String nextToken() Math public static double random()
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSUMMER SEMESTER, 2007Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time allowed: 75 MINUTES)NOTE:Attempt ALL questionsWrite your answers in the space providedThere is space at the back for answer
University of Auckland - COMPSCI - 101
THE UNIVERSITY OF AUCKLANDFIRST SEMESTER, 2008Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time Allowed: TWO hours)NOTE:Attempt ALL questions.Answer Section A (Multiple choice Questions) on the teleform answersheet attached. Answer Secti
University of Auckland - COMPSCI - 101
VERSION 18832768-1-COMPSCI 101THE UNIVERSITY OF AUCKLANDFIRST SEMESTER, 2008Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time Allowed: TWO hours)NOTE:Attempt ALL questions.Answer Section A (Multiple choice Questions) on the teleform an
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDFIRST SEMESTER, 2008Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time allowed: 75 MINUTES)NOTE:Attempt ALL questionsWrite your answers in the space providedThere is space at the back for answers
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDFIRST SEMESTER, 2008Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time allowed: 75 MINUTES)NOTE:Attempt ALL questionsWrite your answers in the space providedThere is space at the back for answers
University of Auckland - COMPSCI - 101
COMPSCI 101THE UNIVERSITY OF AUCKLANDSECOND SEMESTER, 2008Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time allowed: TWO hours)NOTE:Attempt ALL questionsWrite your answers in the space providedThere is space at the back for answers that
University of Auckland - COMPSCI - 101
COMPSCI 101THE UNIVERSITY OF AUCKLANDSECOND SEMESTER, 2008Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time allowed: TWO hours)NOTE:Attempt ALL questionsWrite your answers in the space providedThere is space at the back for answers that
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSECOND SEMESTER, 2008Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time allowed: 75 MINUTES)NOTE:Attempt ALL questionsWrite your answers in the space providedThere is space at the back for answer
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSECOND SEMESTER, 2008Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time allowed: 75 MINUTES)NOTE:Attempt ALL questionsWrite your answers in the space providedThere is space at the back for answer
University of Auckland - COMPSCI - 101
COMPSCI 101THE UNIVERSITY OF AUCKLANDSUMMER SEMESTER, 2008Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time allowed: TWO hours)NOTE:Attempt ALL questionsWrite your answers in the space providedThere is space at the back for answers that
University of Auckland - COMPSCI - 101
COMPSCI 101THE UNIVERSITY OF AUCKLANDSUMMER SEMESTER, 2008Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time allowed: TWO hours)NOTE:Attempt ALL questionsWrite your answers in the space providedThere is space at the back for answers that
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSUMMER SEMESTER, 2008Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time allowed: 75 MINUTES)NOTE:Attempt ALL questionsWrite your answers in the space providedThere is space at the back for answer
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSUMMER SEMESTER, 2008Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time allowed: 75 MINUTES)NOTE:Attempt ALL questionsWrite your answers in the space providedThere is space at the back for answer
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDFIRST SEMESTER, 2009Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time Allowed: TWO hours)NOTE: Attempt ALL questionsWrite your answers in the space providedThere is space at the back for answers that
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDFIRST SEMESTER, 2009Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time Allowed: TWO hours)NOTE: Attempt ALL questionsWrite your answers in the space providedThere is space at the back for answers that
University of Auckland - COMPSCI - 101
COMPSCI 101THE UNIVERSITY OF AUCKLANDFIRST SEMESTER, 2009Campus: CityTESTCOMPUTER SCIENCEPrinciples of Programming(Time allowed: 75 minutes)NOTE:Attempt ALL questionsWrite your answers in the space providedThere is space at the back for answers
University of Auckland - COMPSCI - 101
COMPSCI 101THE UNIVERSITY OF AUCKLANDFIRST SEMESTER, 2009Campus: CityTESTCOMPUTER SCIENCEPrinciples of Programming(Time allowed: 75 minutes)NOTE:Attempt ALL questionsWrite your answers in the space providedThere is space at the back for answers
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSECOND SEMESTER, 2009Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time Allowed: TWO hours)NOTE:You must answer all questions in this exam.No calculators are permittedAnswer in the space provided in t
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSECOND SEMESTER, 2009Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time Allowed: TWO hours)NOTE:You must answer all questions in this exam.No calculators are permittedAnswer in the space provided in t
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSEMESTER TWO, 2009Campus: CityCompSci 101TESTCOMPUTER SCIENCEPrinciples of Programming(Time allowed: 75 minutes)NOTE:Attempt ALL questionsWrite your answers in the space providedThere is space at the back f
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSEMESTER TWO, 2009Campus: CityCompSci 101TESTCOMPUTER SCIENCEPrinciples of Programming(Time allowed: 75 minutes)NOTE:Attempt ALL questionsWrite your answers in the space providedThere is space at the back f
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSUMMER SEMESTER, 2009Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time Allowed: TWO hours)NOTE: Attempt ALL questionsWrite your answers in the space providedThere is space at the back for answers that
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSUMMER SEMESTER, 2009Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time Allowed: TWO hours)NOTE: Attempt ALL questionsWrite your answers in the space providedThere is space at the back for answers that
University of Auckland - COMPSCI - 101
CompSci 101Question/Answer Sheet- Page 2 -CompSci 101 SS CSURNAME: . FORENAMES: .THE UNIVERSITY OF AUCKLANDQuestion 1 (40 marks)a) What output is produced by the following code?String sentence = &quot;I LOVE SUMMER SCHOOL!&quot;;String part = sentence.subs
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSUMMER SEMESTER, 2009Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time allowed: 75 MINUTES)NOTE: Attempt ALL questionsWrite your answers in the space providedThere is space at the back for answer
University of Auckland - COMPSCI - 101
VERSION 00000001COMPSCI 101THE UNIVERSITY OF AUCKLANDFIRST SEMESTER, 2010Campus: CityComputer SciencePrinciples of Programming(Time Allowed: TWO HOURS)SECTION A Question BookletNote: The use of calculators is NOT permitted. You should separate
University of Auckland - COMPSCI - 101
VERSION 00000001COMPSCI 101THE UNIVERSITY OF AUCKLANDFIRST SEMESTER, 2010Campus: CityComputer SciencePrinciples of Programming(Time Allowed: TWO HOURS)SECTION A Question BookletNote: The use of calculators is NOT permitted. You should separate
University of Auckland - COMPSCI - 101
VERSION 00000003COMPSCI 101THE UNIVERSITY OF AUCKLANDFIRST SEMESTER, 2010Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time Allowed: 75 minutes)Note: The use of calculators is NOT permitted. Compare the test version number on the Te
University of Auckland - COMPSCI - 101
VERSION 00000003COMPSCI 101THE UNIVERSITY OF AUCKLANDFIRST SEMESTER, 2010Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time Allowed: 75 minutes)Note: The use of calculators is NOT permitted. Compare the test version number on the Te
University of Auckland - COMPSCI - 101
THE UNIVERSITY OF AUCKLANDSECOND SEMESTER, 2010Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time Allowed: TWO hours)NOTE:You must answer all questions in this exam.No calculators are permittedAnswer in the space provided in this booklet.
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSECOND SEMESTER, 2010Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time Allowed: TWO hours)NOTE:You must answer all questions in this exam.No calculators are permittedAnswer in the space provided in t
University of Auckland - COMPSCI - 101
THE UNIVERSITY OF AUCKLANDSECOND SEMESTER, 2010Campus: CityCOMPUTER SCIENCETEST SOLUTIONSPrinciples of Programming(Time Allowed: 75 minutes)NOTE:You must answer all questions in this test.No calculators are permittedAnswer in the space provided
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSECOND SEMESTER, 2010Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time Allowed: 75 minutes)NOTE:You must answer all questions in this test.No calculators are permittedAnswer in the space provide
University of Auckland - COMPSCI - 101
Question/Answer SheetCompSci101THE UNIVERSITY OF AUCKLANDSUMMER SEMESTER, 2010Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time Allowed: TWO hours)NOTE:You must answer all questions in this exam.No calculators are permittedAnswer in th
University of Auckland - COMPSCI - 101
Question/Answer SheetCompSci101THE UNIVERSITY OF AUCKLANDSUMMER SEMESTER, 2010Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time Allowed: TWO hours)NOTE:You must answer all questions in this exam.No calculators are permittedAnswer in th
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSUMMER SEMESTER, 2010Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time Allowed: 75 minutes)NOTE:You must answer all questions in this test.No calculators are permittedAnswer in the space provide
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSUMMER SEMESTER, 2010Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time Allowed: 75 minutes)NOTE:You must answer all questions in this test.No calculators are permittedAnswer in the space provide
University of Auckland - COMPSCI - 101
VERSION 00000001COMPSCI 101THE UNIVERSITY OF AUCKLANDFIRST SEMESTER, 2011Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time Allowed: TWO hours)Note: The use of calculators is NOT permitted. You should separate the Section A Question Book
University of Auckland - COMPSCI - 101
VERSION 00000001COMPSCI 101THE UNIVERSITY OF AUCKLANDFIRST SEMESTER, 2011Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time Allowed: TWO hours)Note: The use of calculators is NOT permitted. You should separate the Section A Question Book
University of Auckland - COMPSCI - 101
VERSION 00000003COMPSCI 101THE UNIVERSITY OF AUCKLANDFIRST SEMESTER, 2011Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time Allowed: 75 minutes)Note: The use of calculators is NOT permitted. For Section A, use a dark pencil to mark
University of Auckland - COMPSCI - 101
VERSION 00000003COMPSCI 101THE UNIVERSITY OF AUCKLANDFIRST SEMESTER, 2011Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time Allowed: 75 minutes)Note: The use of calculators is NOT permitted. For Section A, use a dark pencil to mark
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSECOND SEMESTER, 2011Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time Allowed: TWO hours)NOTE:You must answer all questions in this test.No calculators are permittedAnswer in the spaces provided in
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSECOND SEMESTER, 2011Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time Allowed: TWO hours)NOTE:You must answer all questions in this test.No calculators are permittedAnswer in the spaces provided in
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSECOND SEMESTER, 2011Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time Allowed: 75 minutes)NOTE:You must answer all questions in this test.No calculators are permittedAnswer in the spaces provid
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSECOND SEMESTER, 2011Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time Allowed: 75 minutes)NOTE:You must answer all questions in this test.No calculators are permittedAnswer in the spaces provid
University of Auckland - COMPSCI - 101
THE UNIVERSITY OF AUCKLANDSUMMER SEMESTER, 2011Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time Allowed: TWO hours)NOTE:You must answer all questions in this exam.No calculators are permittedAnswer in the space provided in this booklet.
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSUMMER SEMESTER, 2011Campus: CityCOMPUTER SCIENCEPrinciples of Programming(Time Allowed: TWO hours)NOTE:You must answer all questions in this exam.No calculators are permittedAnswer in the space provided in t
University of Auckland - COMPSCI - 101
THE UNIVERSITY OF AUCKLANDSUMMER SEMESTER, 2011Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time Allowed: 75 minutes)NOTE:You must answer all questions in this test.No calculators are permittedAnswer in the space provided in this bo
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSUMMER SEMESTER, 2011Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time Allowed: 75 minutes)NOTE:You must answer all questions in this test.No calculators are permittedAnswer in the space provide
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSUMMER SEMESTER, 2012Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time Allowed: 75 minutes)NOTE:You must answer all questions in this test.No calculators are permittedAnswer in the space provide
University of Auckland - COMPSCI - 101
CompSci 101THE UNIVERSITY OF AUCKLANDSUMMER SEMESTER, 2012Campus: CityCOMPUTER SCIENCETESTPrinciples of Programming(Time Allowed: 75 minutes)NOTE:You must answer all questions in this test.No calculators are permittedAnswer in the space provide
University of Auckland - COMPSCI - 101
COMPSCI 101SUMMER SCHOOL2012- Principles of Programming Lecture times and locations (rooms subject to change)Monday: 10:00 am - 11:00 am ClockT029/105-029 (ClockTower building)Tuesday: 10:00 am - 11:00 am ALR5/421W-301 (Architecture building)Wednesd
University of Auckland - COMPSCI - 101
2!Welcome to CompSci 1 1!Will be available on the web!Introduction to the Compsci 101 course!!Algorithms!!Programming steps!!!Lab One Worksheet!Course Information Document3!CompSci 101 People!People cont.!Ann Cameron (Lab Supervisor) !!4
University of Auckland - COMPSCI - 101
Computer Science 1 1 SS CLecture 2 Contents!2!Computer Organisation!Most computers consist of three major components:Compilers, interpreters and java!javac, java commands!Installing Java!Writing the &quot;Hello World&quot; program!!Coursebook: 1! a proce
University of Auckland - COMPSCI - 101
Computer Science 1 1 SS CLecture 3 Contents!2!Review!Write the source code for the application (whichstarts the program).Java Syntax!Displaying Output!MyApplication.javapublic class MyApplication cfw_public static void main(String[] args) cfw_M
University of Auckland - COMPSCI - 101
Computer Science 1 1 SS CLecture 4 Contents!2!Review!What is the output of the following two programs?Java has eight primitive types!Storing information - variables!The assignment statement!Expressions !Modulus!Increment, decrement operators!!
University of Auckland - COMPSCI - 101
Computer Science 1 1 SS C Lecture 5 Contents&quot;&gt; java ReviewAppDeposit $455Current balance $955.535Review&quot;1 public class Review cfw_public void start() cfw_2int amount, leftOvers;3 double balance; 4amount = 435;5 6 l
University of Auckland - COMPSCI - 101
Computer Science 1 1 SS C Lecture 6 Contents&quot;Java - supports object orientedprogramming!2!The world is made up of real world objects e.g.students, dogs, cars, cats, books. !Objects!String objects!String instance methods!!Coursebook: 6!!Object
University of Auckland - COMPSCI - 101
Computer Science 1 1 SS C Lecture 7 Contents&quot;13 blocksLook at the following program which, given the number ofhours and minutes, evaluates the number of complete tenminute blocks.Dening methods: !parameters, !return values, !return statement !!
University of Auckland - COMPSCI - 101
Computer Science 1 1 SS C Lecture 9 Contents&quot;e0Review&quot;Methods!Scope of variables!Reasons for using methods&quot;!!Coursebook: 9!!Methods and parameters what is the output?!1public class MyProgram cfw_public void start() cfw_int x
University of Auckland - COMPSCI - 101
Computer Science 1 1 SS C Lecture 10 Contents&quot;1 String a, b;a2 = new String(&quot;mbc&quot;);b3 = a;4 = b.substring(0, 1);a5 System.out.println(a + b);More String instance methods !2!mmbcReview&quot;!boolean variab