Quiz - Ryerson University Department of Electrical &...

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

View Full Document Right Arrow Icon
Ryerson University Department of Electrical & Computer Engineering COE318 Quiz September 26, 2006 Name:_______________ Student # :________ Time: 30 minutes. Examiner: K. Clowes, T. Yang. Answer all of the following questions in the space provided. Closed book. _____________________________________________________________ (1) What does the following program print out? class Student { int id = 1; String university; public static void main(String [] args) { int x = 0; Student [] st= new Student[4]; while (x < 2) { st st[x] = new Student(); st[x].id = x; st[x].university = "Ryerson"; x =x +1; } null id=1 “Ryerson” id =0 “Ryerson” st[3] =st[1]; st[2] =st[0]; st[0] =st[3]; for (int j=0; j<4; j++) System.out.println ("Student["+j +"]:"+st[j].id); } } Answer: Student[0]:1 Student[1]:1 Student[2]:0 Student[3]:1
Background image of page 1

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

View Full DocumentRight Arrow Icon
Name:________________________ Section:________ (2) What does the following program print out? class Prob1
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.

Page1 / 3

Quiz - Ryerson University Department of Electrical &amp;...

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