2000ACTestQuestions

2000ACTestQuestions - 415.101AC 2000 Principles of...

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

View Full Document Right Arrow Icon
415.101AC 2000 Principles of Programming Test: Monday 31 st January 3.00pm – 4.30pm Surname (Family Name): First Name(s): ID Number: TUESDAY/WEDNESDAY Lab Time: Note: Attempt ALL questions. Calculators are NOT permitted. Write your answers in the spaces provided. There is space at the back for answers that overflow the allotted space. Questions total 72 Marks . Section Marks Possible Marks Q.1 5 Q.2 5 Q.3 8 Q.4 8 Q.5 8 Q.6 4 Q.7 12 Q.8 7 Q.9 5 Q.10 10 Total 72
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.101AC Test January 31 2000 page 2 Question 1 (5 marks) Have a look at the following HTML source code: <html> <head><title>Terms Test</title></head> <body> <h1>Computer Science</h1> <hr> <img src = "101.gif"> <hr> This <a href = "http://www.cs.auckland.ac.nz/415.101AC">course</a> is: <ul> <li>fun</li> <li>interesting</li> </ul> </body> </html> Note: the file 101.gif is a gif image file which looks like this: Draw the output from the HTML code above in the browser window below:
Background image of page 2
415.101AC Test January 31 2000 page 3 Question 2 (5 marks) Rewrite the following program using the standard 415.101 indentation. public class Q2 { public static void main(String args[]) { int int1, int2; System.out.println("Numbers: "); int1 = Keyboard.readInt(); int2 = Keyboard.readInt(); if (int1 > 62){ System.out.println("OK"); int1 = int1 - 3; } else { int1 = int1 + 10; if (int1 > int2) System.out.println(int1 + ", "+ int2); else { int1 = int1 - 10; System.out.println(int1 + ", "+ int2); }}}} public class Q2 { public static void main(String args[]) { int int1, int2; System.out.println("Numbers: "); int1 = Keyboard.readInt(); int2 = Keyboard.readInt();
Background image of page 3

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

View Full DocumentRight Arrow Icon
415.101AC Test January 31 2000 page 4 Question 3 (8 marks) What is the output when the following program is run? public class Q3 { public static void main(String args[]) { int int1, int2, int3; double double1, double2, double3; long long1; double1 = 12.0; double2 = 5.0; int2 = 2; int1 = (int)double1 / (int)double2; double3 = (6 * (int)double2) / double1; long1 = Math.min(int2, (int)Math.pow(1.0, double2)); int3 = (10 * int2) % (int)double1; System.out.println("int1: " + int1); System.out.println("int3: " + int3); System.out.println("double3: " + double3); System.out.println("long1: " + long1); } }
Background image of page 4
415.101AC Test January 31 2000 page 5 Question 4 (8 marks) What is the output of the following Applet? import java.applet.*; public class Q4 extends Applet { int a; boolean b; double c; public void init() { a = 20; b = true; c = 1.5; first(a); c = second() + third(b); System.out.println("a is: " + a); System.out.println("b is: " + b); System.out.println("c is: " + c); }
Background image of page 5

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

View Full DocumentRight Arrow Icon
Image of page 6
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 / 18

2000ACTestQuestions - 415.101AC 2000 Principles of...

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

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