Java Program - Advanced Applications Programming - Exam, Exams of Applications of Computer Sciences

Java Program, Main Method, Helper Methods, Writing Programs, Graphical User, Packages, Array is Created, Default Constructor, Concrete Method, Boolean Expression are points of Advanced Applications Programming course exam.

Typology: Exams

2011/2012

Uploaded on 11/24/2012

divye
divye 🇮🇳

4.6

(12)

92 documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
!
Semester II Examinations 2010
Exam Code(s)
1AE1, 1MIS1, 1MIS2
Exam(s)
Masters of Business Studies in Electronic Commerce
MSc. Information Systems Management full-time
MSc. Information Systems Management part-time
Module Code(s)
MS815
Module(s)
Advanced Application Programming
Paper No.
Repeat Paper
External Examiner(s)
Dr. Danail Ivanov
Internal Examiner(s)
Dr. Tom Acton
Mr. Seamus Hill
Instructions:
Candidates are required to answer:
Section A (20 Marks) Answer all 10 parts of section A,
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
3 hrs
Accountancy & Finance
Requirements:
MCQ
Yes, Type a-d
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
!
pf3
pf4
pf5

Partial preview of the text

Download Java Program - Advanced Applications Programming - Exam and more Exams Applications of Computer Sciences in PDF only on Docsity!

Semester II Examinations 2010

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) MS8 15 Module(s) Advanced Application Programming Paper No. Repeat Paper External Examiner(s) Dr. Danail Ivanov Internal Examiner(s) Dr. Tom Acton Mr. Seamus Hill Instructions: Candidates are required to answer: Section A (20 Marks) Answer all 10 parts of section A, 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 hrs Department(s) Accountancy & Finance Course Co-ordinator(s) Requirements : MCQ Yes, Type a-d

Section A (20 Marks)

Attempt all 10 questions

Mark your answers on the MCQ sheet provided

1 ) When a Java program runs, which of the following methods is run first?

a) The main method

b) The executable method

c) The class method

d) The helper methods

2 ) Before one can begin writing programs that can take user input through a graphical user

interface, ___________ must be imported.

a) java.io.*;

b) javax.swing.*;

c) java.packages.output.*;

d) java.sys.*;

3) When an array is passed to a method ________________.

a) only the reference is passed, and a copy of the array is not created in the

method.

b) a copy of the array is created within the method.

c) the value of the array is passed into the method.

d) None of the above.

4) A(n) ______________ has a method prototype but no body.

a) default constructor

b) default method

c) concrete method

d) abstract method

5) An assertion is ________________.

a) A mechanism to improve the likelihood of catching logical errors during program

development.

b) A synonym for a typical Java statement.

c) A conclusion or stance that was drawn based on reasoning.

d) A logical, usually Boolean expression.

Section B (80 Marks)

Answer Any TWO Questions

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.

2 abstract class Student { 3 4 protected final static int NUM_OF_TESTS = 3; 5 6 protected String name; 7 8 protected int[] test; 9 10 protected String courseGrade; 11 12 public Student( ) { 13 this("No Name"); 14 } 15 16 public Student(String studentName) { 17 name = studentName; 18 test = new int[NUM_OF_TESTS]; 19 courseGrade = "****"; 20 } 21 22 abstract public void computeCourseGrade(); 23 24 public String getCourseGrade( ) { 25 return courseGrade; 26 } 27 28 public String getName( ) { 29 return name; 30 } 31 32 public int getTestScore(int testNumber) { 33 return test[testNumber-1]; 34 } 35 36 public void setName(String newName) { 37 name = newName; 38 } 39 40 public void setTestScore(int testNumber, int testScore) { 41 test[testNumber-1] = testScore; 42 } 43 44 } 45 46

47 class UndergraduateStudent extends Student { 48 49 50 public void computeCourseGrade() { 51 int total = 0; 52 53 for (int i = 0; i < NUM_OF_TESTS; i++) { 54 total += test[i]; 55 } 56 57 if (total / NUM_OF_TESTS >= 70) { 58 courseGrade = "Pass"; 59 } else { 60 courseGrade = "Fail"; 61 } 62 } 63 } 64 65 class GraduateStudent extends Student { 66 67 public void computeCourseGrade() { 68 int total = 0; 69 70 for (int i = 0; i < NUM_OF_TESTS; i++) { 71 total += test[i]; 72 } 73 74 if (total / NUM_OF_TESTS >= 80) { 75 courseGrade = "Pass"; 76 } else { 77 courseGrade = "No Pass"; 78 } 79 } 80 } 81 82 83 public class students { 84 85 public static void main(String[] args) { 86 Student[] roster = new Student[5]; 87 roster[0] = new GraduateStudent(); 88 roster[1] = new UndergraduateStudent(); 89 roster[2] = new UndergraduateStudent(); 90 roster[3] = new GraduateStudent(); 91 roster[4] = new GraduateStudent(); 92 for (int i = 0; i < roster.length; i++) { 93 roster[i].setTestScore(1, 70); 94 roster[i].setTestScore(2, 70); 95 roster[i].setTestScore(3, 70); 96 } 97 for (int i = 0; i < roster.length; i++) { 98 roster[i].computeCourseGrade(); 99 } 100 for (int i = 0; i < roster.length; i++) { 101 System.out.println("Grade " + roster[i].getCourseGrade()); 102 } 103 } 104 105 }

(40 Marks)

Part b)

Define a new class named Temperature. The class has two accessors — toFahrenheit and

toCelsius—that return the temperature in the specified unit and two mutators —

setFahrenheit and setCelsius—that assign the temperature in the specified unit. Maintain

the temperature internally in degrees Fahrenheit.

Using this class, write a program that inputs temperature in degrees Fahrenheit and

outputs the temperature in equivalent degrees Celsius.

The input and output should resemble the following;

Enter temperature in fahreneit (e.g. 88): 80 Input: 80.0F is equivalent to Output: 26.67C

You should use the formula ( 5.0 / 9.0 ) * ( fahrenheit - 32 ) to convert from Fahrenheit to

Celsius - Where fahrenheit is the variable used to hold the number imputed by the user.

(30 Marks)

Question 4

Part a)

In relation to object-oriented programming with JAVA, detail your understanding, using

examples/analogies where appropriate, of each of the following:

i. Polymorphism,

ii. Overloaded Constructors

iii. Inheritance

iv. Pass by reference and pass by value.

(20 Marks)

Part b)

In relation to the visibility of data members, discuss the effects of the modifiers protected ,

public and private , using examples where appropriate.

(8 Marks)

Part c)

Briefly discuss, using examples/analogies where appropriate, the following statement -

Public methods of a class determine the behaviour of its instances. Internal details are

implemented by private methods and private data members.

(12 Marks)