Put no 3 marks question 25 3 marks give the result of

This preview shows page 6 - 8 out of 8 pages.

put no (3 marks) Question 25 (3 marks) Give the result of the following expressions. a) true b) false c) invalid, "5 < a" evaluates to true but can't compare boolean against int (i.e.,"true < 12"). (3 marks)
Image of page 6

Subscribe to view the full document.

Answer Sheet - 7 - COMPSCI 101 ID ........................................ CONTINUED Question 26 (4 marks) Give the corresponding while loop. int a = 0; while (a < 10) { System.out.println(a); a++; } (4 marks) Question 27 (6 marks) State the letter of the lines on which the errors occur, and give a correction for each error. Line b: Conditional test is actually an assignment statement. This should be changed to x == 5 Line c: The statement, return 10.0, does not match the return type of the method. This should be changed to return 10, or the return type should be changed to be double (6 marks) Question 28 (12 marks) Complete the method definition below. private int[ ] duplicate(int[ ] original) { int [ ] copy = new int [original.length]; for (int i = 0; i < original.length; i++) { copy[i] = original[i]; } return(copy); } (12 marks)
Image of page 7