138x Filetype PDF File size 0.08 MB Source: ecs.wgtn.ac.nz
FamilyName:.............................. OtherNames: ............................. StudentID:................................ Signature.................................. Intro to ComputerProgramming: FinalExam 09January, 2017 Instructions • Timeallowed: 2Hours • Answerallthequestions. Thereare 70marks in total. • Write youranswersintheboxesin thistestpaperandhandinallsheets. • If you think some question is unclear, ask for clarification. • Brief Java documentation is provided with the test • This test contributes 15% of your final grade (But your mark will be boosted up to your exam mark if that is higher.) • Youmayusepapertranslationdictionaries,andcalculatorswithoutafullsetofalpha- bet keys. • Youmaywritenotesandworkingonthispaper,butmakesureyouranswersareclear. Questions Marks 1. UnderstandingJava [25] 2. Files and Arraylists of objects [15] 3. Writing methodsthat use objects [10] 4. Arrays and2Darrays [20] TOTAL: StudentID: ....................... SPAREPAGEFOREXTRAANSWERS Crossoutroughworkingthatyoudonotwantmarked. Specify the question number for work that you do want marked. Intro to ComputerProgramming(FinalExam) Page2of15 StudentID: ....................... Question1. UnderstandingJava [25 marks] (a) [5 marks] Understandingparameterpassingandmethodscalling sequence WhatwillbeprintedoutifthemainmethodofthefollowingThingclassiscalled? public class Thing { public Thing() { UI. println ("Initialsing......."); } public void incrementThenAdd(int x) { x++; UI. println ("Value = " + x); } public static void main(String[ ] args) { Thing obj = new Thing(); int y = 10; obj.incrementThenAdd(y); UI. println ("Value = " + y); } } (Question1 continuedonnextpage) Intro to ComputerProgramming(FinalExam) Page3of15 StudentID: ....................... (Question 1 continued) (b) [5 marks] Understandingloops WhatwillbeprintedifthefollowingdoSomethingmethodiscalled? public void doSomething() { for(int i = 0; i< 5; i++) { for(int j = 0; j< 5−i; j++) { UI.print("X"); } UI.print("\n"); } UI. println ("done"); } Intro to ComputerProgramming(FinalExam) Page4of15
no reviews yet
Please Login to review.