COMP-202--final-exam--2008-12.pdf

54 views19 pages
First Name:Last Name:
McGill ID:Section:
Faculty of Science
COMP-202A - Introduction to Computing I (Fall 2008)
Final Examination
Thursday, December 11, 2008 Examiners: Mathieu Petitpas [Section 1]
14:00–17:00 Prof. Paul Kry [Section 2]
Gregory B. Prokopski [Section 3]
Instructions:
DO NOT TURN THIS PAGE UNTIL INSTRUCTED
This is a closed book examination; notes, slides, textbooks, and other forms of documentation are not
allowed.
Non-programmable calculators are allowed (though you should not need one).
Computers, PDAs, cell phones, and other electronic devices are not allowed.
Answer all questions on the examination paper; if you need additional space, use page 16 or the
booklets supplied and clearly indicate where each question is continued. In order to receive full
marks, you must show all work.
This final examination has 19 pages including this cover page. Pages 17-19 can be detached from
the rest of the examination for easy reference and do not have to be returned.
1 2 Subtotal
/10 /5 /15
3 4 5 Subtotal
/10 /10 /15 /35
6 7 8 Subtotal
/20 /15 /15 /50
Total
/100
1
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 19 pages and 3 million more documents.

Already have an account? Log in
COMP-202A - Fall 2008 - Final Examination Page 2
Section 1 - Short Questions
1. In one or two sentences, explain the differences between the concepts in each of the following pairs.[10]
BE BRIEF; overly long answers will be grounds for mark deductions.
(a) throw and throws
(b) while and do while
(c) local variables and instance variables
(d) iteration and recursion
(e) classes and objects
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 19 pages and 3 million more documents.

Already have an account? Log in
COMP-202A - Fall 2008 - Final Examination Page 3
2. What does the following program display?[5]
public class X {
private char x = ’x’;
public X() {
System.out.println("A x=" + x + "\t this.x=" + this.x );
}
public void x() {
System.out.println("B x=" + x + "\t this.x=" + this.x );
}
public void x( char x ) {
System.out.println("C x=" + x + "\t this.x=" + this.x );
}
public void x( long x ) {
System.out.println("D x=" + x + "\t this.x=" + this.x );
}
public void x( double x ) {
System.out.println("E x=" + x + "\t this.x=" + this.x );
}
public void x( String x ) {
System.out.println("F x=" + x + "\t this.x=" + this.x );
}
public static void main( String[] args ) {
try {
X x = new X();
x.x( );
x.x( 1 );
x.x( 2.0f );
x.x( ’3’ );
x.x( 4L );
x.x( 5.0 );
x.x( "6" );
} catch ( Exception x ) {
System.err.println("Avenge my death!");
}
}
}
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 19 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+
$10 USD/m
Billed $120 USD annually
Homework Help
Class Notes
Textbook Notes
40 Verified Answers
Study Guides
1 Booster Class