Sei sulla pagina 1di 7
INTI International College Subang auneaTe NTsNATIONAL VERSES: FINAL "Examination Paper (COVER PAGE) Session August 2012 Programme Diploma In Infocmaton snd Communication Teshnology (DICT) Course CSC2100: Object-Oriented Programming ate of Examination: _December 13,2012 (Thursday) Time 500pm~7.0pm ___ Reading Time Nil Duration 2 Hours Special Insructions ‘This paper consists of SIX (6) questions. Answer any FOUR (8) questions inthe answer book Provided. All questions cay oqualmayks. Materials permite Nil Material provided Nil Examiner Ms Ng Ruoh Ling Moderator De Ang Tan Fong ‘This paper consists of7 printed pages, including the cover page. CSC2100(E) / Page 1 of 6 INTHINTERNATIONAL COLLEGE SUBANG DIPLOMA IN INFORMATION AND COMMUNICATION TECHNOLOGY PROGRAMME. «wicrh, (€SC2100 : OBJECT-ORIENTED PROGRAMMING FINAL EXAMINATION: AUGUST 2012 SESSION Instructions: Ths paper consists of SIX (6) questions. Answer any FOUR (4) questions in the answer booklet provided. Al questions cary equal marks, Question 1 {(@) Discuss THREE 3) :ypes of loop structure with examples. (marks) (©) Waite the program segment (within the main) that prin dhe following V shape using rest for loop. Note that the number of rows to form the V is decided by the user (minimum 2 rows is required) and you ean ony print the har symbol (*") and the char space ("in your nesed for loop. (masks) (©) Teace the output ofthe following program: public class te { public static vold main(string (Jarg) (char () array = C13" "any Tay "at, tat at, a, fate String word ~ "Steel String message ~ "Woodworking project’ String output = message. replace (*Rood” word) + Systen.out-printin (message. substring (21) systen-oat _printIn message. substring (4,11); systen.out -println output} essage.getchars (1, 10,ar20y/5) for(int in0; iearray.lengohy #4) Systen.out print (array[i}|7 Systen.out printin(} System-out .prant in message. regionfatenes (3, output, 9, 4)17 System.out .print1n (output. valuoot (4) masks) C3C2100(F) / Page 2 of 6 Question? @ © © Write program that store all the 26 alphabet (a ~2) into an array of char. Randomly pick an alphabet from the array and ask the user to guess the picked alphabet. Show appropriate message I"Cortect” or "Wrong”) based on the input. User is given maximum Of 3 guesses before the program shows the correct answer (10 marks) ‘Waite the overloading methods that return the bigger value between two parameters. The first method compares wo parameters of char type; the second method compares Wo perumeters of String pe. 6 mais) _Explsin and fix the syntax or runtime errors of the following programm fragments: @ public vaid rotaltint 2, int y) [return ty? : marks) Gi) Float sates: Float interest system-out.printin(*raterest ymned Le RMeinterest); 2 marks) Gi) char Letter = soptionPane. showtnputDialog( Systencout pristiateieur input letter is “vlettor); @ mats) iv) Ane. counter=t, sun-02 sini ie(eounter3) to sum+-counters Syoten.out.printla (eum + , marks)

Potrebbero piacerti anche