Objects and Classes - Advanced Applications Programming - Exam, Exams of Applications of Computer Sciences

Objects and Classes, Programming, Standard Classes, Programmer Defined Classes, Strict Formatting Regulations, Automatically after Compilation, Level of Fuel, Public Void Getsize, Static Void Getsize, Access Modifier 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
Autumn Examinations 2011/ 2012
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. Michael Lang
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 Hours
No. of Pages
Discipline(s)
Business Information Systems
Course Co-
ordinator(s)
Mr. Seamus Hill
Requirements:
MCQ
Release to Library: Yes No
YES
Handout
Statistical/ Log
Tables
Cambridge Tables
Graph Paper
Log Graph Paper
Other Materials
PTO
pf3
pf4
pf5

Partial preview of the text

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

Autumn Examinations 2011/ 2012

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

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 Hours

No. of Pages

Discipline(s) Business Information Systems

Course Co-

ordinator(s)

Mr. Seamus Hill

Requirements :

MCQ

Release to Library: Yes No

YES

Handout

Statistical/ Log

Tables

Cambridge Tables

Graph Paper

Log Graph Paper

Other Materials

PTO

Question 1

  1. What are the two most important concepts in object-oriented programming?

a) objects and programming b) objects and orientation c) objects and classes d) objects and inheritance

  1. What is the difference between programmer-defined classes and standard classes?

a) Programmer-defined classes are always written after standard classes. b) Programmer-defined classes can be named anything the user chooses, while standard classes have strict formatting regulations. c) Programmer-defined classes are written by the programmer, while standard classes are built into Java. d) Programmer-defined classes are written by the programmer, while standard classes are created automatically after compilation.

  1. 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.

  1. We are writing a program to model the behavior of a car. Which of the following is a valid candidate to be represented with a constant as opposed to a variable?

a) The level of fuel in the gas tank. b) The maximum speed that the speedometer can read. c) The number represented by the car’s odometer. d) The number of miles to the next oil change.

  1. Assume a program uses a Class, FurnitureStore, which contains a method called “getSize” that is used as follows: FurnitureStore fs = new FurnitureStore(30, “LazyBoy”); int size = fs.getSize();

Which of the following is the prototype for the getSize method? a) public void getSize(int); b) public static void getSize(); c) public int getSize(); d) public int getSize(int);

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 import javax.swing.*; 2 3 class HiLo { 4 5 private final int MAX_GUESS_ALLOWED = 6; 6 7 private final int LOWER_BOUND = 1; 8 9 private final int UPPER_BOUND = 100; 10 11 private int secretNumber; 12 13 public HiLo( ) { 14 15 } 16 17 public static void main (String[] args) { 18 HiLo hiLo = new HiLo( ); 19 hiLo.start(); 20 } 21 22 public void start ( ) { 23 int answer; 24 25 answer = prompt("Do you want to play a Hi-Lo game?"); 26 27 while (answer == JOptionPane.YES_OPTION) { 28 29 generateSecretNumber( ); 30 31 playGame(); 32 33 answer = prompt("Do you want to play another Hi-Lo game?"); 34 } 35 } 36

Section B (80 Marks) Answer Any TWO Questions

37 private void generateSecretNumber( ) { 38 39 double X = Math.random(); 40 41 secretNumber = (int) Math.floor(X*100) + 1; 42 43 System.out.println("Secret Number: " + secretNumber); //TEMP 44 } 45 46 private int getNextGuess( ) { 47 48 String inputStr; 49 int input; 50 51 while (true) { 52 inputStr = JOptionPane.showInputDialog(null,"Next Guess"); 53 input = Integer.parseInt(inputStr); 54 55 if (LOWER_BOUND <= input && input <= UPPER_BOUND) { 56 return input; 57 } 58 59 JOptionPane.showMessageDialog(null, "Invalid Input: " + 60 "Must be between " + LOWER_BOUND + 61 "and " + UPPER_BOUND); 62 } 63 } 64 65 private void playGame( ) { 66 67 int guessCount = 0; 68 int guess; 69 70 do { 71 guess = getNextGuess(); 72 73 guessCount++; 74 75 if (guess < secretNumber) { 76 77 JOptionPane.showMessageDialog(null, "Your guess is LO"); 78 79 } else if (guess > secretNumber) { 80 81 JOptionPane.showMessageDialog(null, "Your guess is HI"); 82 } 83 84 } while ( guessCount < MAX_GUESS_ALLOWED && 85 guess != secretNumber ); 86 87 if ( guess == secretNumber ) { 88 89 JOptionPane.showMessageDialog(null, "You guessed it in " 90 + guessCount + " tries."); 91 } else {

Question 3.

a) In relation to object-oriented programming with JAVA, detail your understanding, using examples/analogies where appropriate, of each of the following:

i. Exception thrower, ii. Exception Catcher iii. Exception Propagator iv. Checked exception. (Marks 10)

b) Write a program that displays the recommended weight, given the user’s age and height. The formula for calculating the recommended weight is;

recommendedWeight = (height – 100 + age / 10) * 0.

Define a service class named Height and include an appropriate method for getting a recommended weight of a designated height. Your program should include a programmer defined class Height and a main class WeightRecommender

Use JOptionPane to get age and height input from the use.

(Marks 30)

Question 4.

a) Polymorphism makes possible smooth and easy extension and modification of

a program

Discuss the above statement using examples to illustrate your answer.

(Marks 20)

b) Describe each of the following concepts as they relate to Java, using examples to illustrate your answers.

i. Polymorphic messages

ii. Inheritance and visibility modifiers

iii. Inheritance versus Interface

iv. Inheritance and constructors

(Marks 20)