2000FCTestQuestions

2000FCTestQuestions - 4 15.101FC PRINCIPLES OF PROGRAMMING...

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

View Full Document Right Arrow Icon
415.101FC PRINCIPLES OF PROGRAMMING Test – Tuesday 11th April 2000 6:30pm - 8:00pm INSTRUCTIONS This test constitutes 15% of your final grade for the course. You have 5 minutes reading time. Do not write until you are told. No one is to leave in the last 10 minutes. The test is closed book. No calculators are allowed. There are 100 marks in this test. The marks for each question are at the end of the question. Answer all questions in the answer book provided. Write your name and the day and time of your tutorial on the cover sheet and your ID number on the inside of the cover sheet. Write your name on every page. When you are asked to write code you do NOT have to include Javadoc comments. See the last page for a list of methods and constants you may find useful in your answers. You may use the back of the answer book for rough working.
Background image of page 1

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

View Full DocumentRight Arrow Icon
415.101FC 2000 TEST QUESTION BOOK PAGE 2 1. Draw the output of the following HTML code in the browser window in the answer book. Do not worry about the exact size of fonts, but do show differences between different levels of heading and different styles of text and normal text. <html><head> <title> How to pass a test </title></head> <body> <h1>Want to pass?</h1> Follow these simple steps: <ul> <li>relax</li> <li>make sure you understand <a href = http://www.cs.auckland.ac.nz/lectures/>these</a></li> <li><b>don't</b> spend too long on question one</li> </ul> <hr> </body></html> (5 marks) 2. The following Java application is supposed to simulate the tossing of a coin. Roughly half the time this application is run, the output should be "A head was thrown.", and the other half, the output should be: "A tail was thrown.". public class CoinToss { public void main (String args[]) { toss = (int)Math.random()*2; if (toss = 0) System.out.println("A head was thrown.") else System.out.println("A tail was thrown."); } } However, there are 5 errors in the code above. 4 of these errors are syntax errors which prevent the code from compiling. The fifth error is a logic error, so that even though the code compiles, the program does not behave correctly.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/01/2012 for the course COMPSCI 101 taught by Professor Adrianaferraro during the Summer '12 term at Auckland.

Page1 / 7

2000FCTestQuestions - 4 15.101FC PRINCIPLES OF PROGRAMMING...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online