OOP Final Exam Question 2014/2015 PDF

Title OOP Final Exam Question 2014/2015
Course Object Oriented Programming
Institution Universiti Teknologi Malaysia
Pages 12
File Size 220.5 KB
File Type PDF
Total Downloads 157
Total Views 968

Summary

Question 1 (35 marks) Figure 1 represents the Final program shown in Figure 2. Person Name Student String Final Figure 1: Class Diagram for Final. 2 Download java source codes (Final) from Figure 2 shows the Final source codes for your reference. The program has errors and you are required to debug ...


Description

Question 1

(35 marks)

Figure 1 represents the Final.java program shown in Figure 2.

Person -name:Name -age:int +Person(int) +Person() +Person(String) +getName():String +getAge():int +toString():String

Name

Student

-firstname: String -lastname:String +Student()

+Name(String,String) +getname():String

Final

+static main(String[]):void +getValues(int[]):void

Figure 1: Class Diagram for Final.java.

2

Download java source codes (Final.java) from e-learning. Figure 2 shows the Final.java source codes for your reference. The program has errors and you are required

to debug the errors. Compile and run the program. The program should produce the output, as shown in Figure 3. Marks Distribution: 1) Finding all errors (25 marks). 2) Program able to compile and run successfully (5 marks). 3) Produce the expected output (5 marks) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46

import java.util.Scanner; import java.util.Array; public class Final { public static void main (String [] args) { int [5] myArray = new int []; getValues(myArray); System.out.print("Series of Input inserted: "); System.out.print(myArray); ArrayListmyArrList = new ArrayList(); myArrList.addItem("Kluang"); // Inserts an item String str = (String)myArrList.get(0); myArrList.set(1,"Muar"); // replace at index 0 myArrList.add("Johor Bahru"); System.out.println("\nItems in the arraylist: "); for(int i=0;i...


Similar Free PDFs