




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A set of questions for a java programming exam focused on advanced application programming. The exam covers topics such as constructors, methods, inheritance, polymorphism, and access modifiers. The questions are divided into two sections: multiple-choice questions and essay questions. The multiple-choice questions cover topics such as the order of method execution, data types, and conditional statements. The essay questions require the student to explain the purpose and workings of a given java application and to write a java application that converts temperatures between celsius and fahrenheit.
Typology: Exams
1 / 8
This page cannot be seen from the preview
Don't miss anything!
Exam Code(s) 1AE1, 1MIS1, 1MIS Exam(s) Masters of Business Studies in Electronic Commerce MSc. Information Systems Management full-time MSc. Information Systems Management part-time
Module Code(s) MS Module(s) Advanced Application Programming
Paper No. Repeat Paper
External Examiner(s)
Dr. Danail Ivanov
Internal Examiner(s)
Dr. Michael Lang Mr. Seamus Hill
This section consists of 10 multiple-choice questions all of which should ideally be attempted. Answers are to be written on the MCQ sheet provided, NOT on the Examination paper. Section B (80 Marks) Answer Any Two Questions Duration 3 Hours No. of Pages Discipline(s) Business Information Systems Course Co- ordinator(s)
Mr. Seamus Hill
Requirements : MCQ Release to Library: Yes No Handout Statistical/ Log Tables Cambridge Tables Graph Paper Log Graph Paper Other Materials PTO
X
Question 1
a) The main method b) The executable method c) The class method d) The helper methods
a) numerical data types b) variables c) keywords d) identifiers
a) inheritance b) polyinputting c) overloading d) multiplicity
a) Minimize the number of nestings b) Don’t include too many ANDs and ORs c) Don’t include multiple statements within an if or else block. d) Read code over after it is completed.
a) priming read b) assumed input c) anticipated read d) blind conditional
Section A (20 Marks) Attempt all 10 questions Mark your answers on the MCQ sheet provided
Question 2
Review the following application and explain the purpose of the application and how it works. Explain in detail, the purpose of each the classes and the workings of their methods, using the line numbers for reference.
1 public class CommissionEmployee 2 { 3 private String firstName; 4 private String lastName; 5 private String personalPublicServiceNumber; 6 private double grossSales; 7 private double commissionRate; 8 9 public CommissionEmployee( String first, String last, String ppsn, 10 double sales, double rate ) 11 { 12 firstName = first; 13 lastName = last; 14 personalPublicServiceNumber = ppsn; 15 setGrossSales( sales ); 16 setCommissionRate( rate ); 17 } 18 19 public void setFirstName( String first ) 20 { 21 firstName = first; 22 } 23 24 public String getFirstName() 25 { 26 return firstName; 27 } 28 29 public void setLastName( String last ) 30 { 31 lastName = last; 32 } 33 34 public String getLastName() 35 { 36 return lastName; 37 }
39 public void setPersonalPublicServiceNumber( String ppsn ) 40 { 41 personalPublicServiceNumber = ppsn; 42 } 43 44 public String getPersonalPublicServiceNumber() 45 { 46 return personalPublicServiceNumber; 47 } 48 49 public void setGrossSales( double sales ) 50 { 51 if (sales<0.0) 52 grossSales = 0.00; 53 else 54 grossSales = sales; 55 } 56 57 public double getGrossSales() 58 { 59 return grossSales; 60 } 61 62 public void setCommissionRate( double rate ) 63 { 64 if (rate > 0.0 && rate < 1.0) 65 commissionRate = rate; 66 else 67 commissionRate = 0.0; 68 } 69 70 public double getCommissionRate() 71 { 72 return commissionRate; 73 } 74 75 public double earnings() 76 { 77 return getCommissionRate() * getGrossSales(); 78 } 79
119 public String toString() 120 { 121 return String.format( "%s %s\n%s: %.2f", "base-salaried", 122 super.toString(), "base salary", getBaseSalary() ); 123 } 124 } 125 126 public class Application 127 { 128 public static void main( String[] args ) 129 { 130 CommissionEmployee commissionEmployee = new CommissionEmployee( 131 "Homer", "Simpson", "22222222A", 1000, .05 ); 132 133 BasePlusCommissionEmployee basePlusCommissionEmployee = 134 new BasePlusCommissionEmployee( 135 "Moe", "Szyslak", "11111111G", 500, .02, 250 ); 136 137 System.out.printf( "%s\n\n", commissionEmployee.toString() ); 138 139 System.out.printf( "%s\n", basePlusCommissionEmployee.toString() ); 140 141 CommissionEmployee commissionEmployee2 = basePlusCommissionEmployee; 142 System.out.printf( "\n%s\n", commissionEmployee2.toString() ); 143 } 144 } 145
Question 3.
i. Describe using examples the concept of a copy constructor.
(Marks 10)
ii. Write a java application that allows the user to convert from Celsius to Fahrenheit and from Fahrenheit to Celsius. The application should include a class named Temperature which is to have two accessors (getCelsius & getFahrenheit) and two mutators (setCelsius & setFahrenheit). Using this class write a tester class that firstly, takes input from the user in Celsius and outputs the equivalent temperature in Fahrenheit, and secondly, takes input from the user in Fahrenheit and outputs the equivalent temperature in Celsius.
(Marks 30)
Question 4.
i. Polymorphism makes possible smooth and easy extension and modification of a program
Discuss the above statement using examples to illustrate your answer.
(Marks 20)
ii. Describe each of the following concepts as they relate to Java, using examples to illustrate your answers.
a) Polymorphic messages
b) Inheritance and visibility modifiers
c) Inheritance versus Interface
d) Inheritance and constructors
(Marks 20)