{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Tutorial_2_Sol - CC2203 Data Structures and Algorithms Sem...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CC2203 Data Structures and Algorithms Sem 2, 2009-2010 Page 1 of 2 Tutorial 2 Solutions A1: Recall the rules for forming identifiers in Java programs. a) Valid b) Valid c) Invalid, an identifier cannot start with a digit. d) Valid e) Valid f) Invalid, ‘&’ is not a valid character in an identifier. A2: a) 8 / 3 = 2 b) 8 / 2.25 = 3.55556 c) 8 % 3 = 2 d) 3 % 8 = 3 e) 8 * 3 + 2.25 = 26.25 f) 8 + 3 * 2.25 = 14.75 A3: a) No compile time error produced. If the user types java Test , the user would get a runtime error: "Can't find class Test" because the output of the compilation would be test.class . However, if the user types java test , the user would get no runtime error, since the Java interpreter would find test.class . Note however, that this error only occurs on operating systems that are also case sensitive. b) No compile time or run-time error produced. A slight logical error occurs. The program outputs the word "emergency" instead "Emergency". c) Two compile-time errors will be produced. First, an error message will indicate that ')' is expected; Second, an error message indicates that, at the same line,
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}