IT Bachelor's Exam in Java Programming - Autumn 2006, Exams of Software Development Methodologies

The instructions and questions for a bachelor's exam in computing in information technology at cork institute of technology. The exam covers various topics in java programming, including object-oriented programming, file i/o, sorting arrays, palindromes, and abstract classes. Students are required to write code snippets and complete programs to answer the questions.

Typology: Exams

2012/2013

Uploaded on 03/25/2013

digvijay
digvijay 🇮🇳

4.4

(17)

185 documents

1 / 5

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Cork Institute of Technology
Bachelor of Science in Computing in Information Technology
Support (FT & ACCS) - Award
(NFQ Level 7)
Autumn 2006
Software Development
(Time: 3 Hours)
Instructions
Answer FOUR questions
Examiners: Mr. G. Mac Sweeney
Mr. J. Greenslade
Mr. J. Walsh
1.
a) Write the code to define the class Person() which includes code for the following
methods:
Set a name
Set an age
Return name
Return age
Decide what data variables are required, arguments for methods, etc. (8 Marks)
b) Write a program to create an array of ten Person() objects and read ten names and
ages into the array from the file people.dat.
The first part of the code is as follows:
import java.io.*;
public class Test1 {
public static void main( String args[] ) throws
IOException {
File f = new File("people.dat");
FileInputStream fs = new FileInputStream(f);
InputStreamReader isr;
BufferedReader fileInput;
isr = new InputStreamReader(fs);
fileInput = new BufferedReader(isr);
…….
(
8 Marks)
c) Write a piece of code which sorts the items from the array into order the youngest first.
(
9 Marks)
pf3
pf4
pf5

Partial preview of the text

Download IT Bachelor's Exam in Java Programming - Autumn 2006 and more Exams Software Development Methodologies in PDF only on Docsity!

Cork Institute of Technology

Bachelor of Science in Computing in Information Technology

Support (FT & ACCS) - Award

(NFQ Level 7)

Autumn 2006

Software Development

(Time: 3 Hours)

Instructions Answer FOUR questions

Examiners: Mr. G. Mac Sweeney Mr. J. Greenslade Mr. J. Walsh 1.

a) Write the code to define the class Person() which includes code for the following methods:

  • Set a name
  • Set an age
  • Return name
  • Return age

Decide what data variables are required, arguments for methods, etc. ( 8 Marks )

b) Write a program to create an array of ten Person() objects and read ten names and ages into the array from the file people.dat.

The first part of the code is as follows:

import java.io.*; public class Test1 { public static void main( String args[] ) throws IOException {

File f = new File("people.dat"); FileInputStream fs = new FileInputStream(f); InputStreamReader isr; BufferedReader fileInput; isr = new InputStreamReader(fs); fileInput = new BufferedReader(isr); ……. ( 8 Marks )

c) Write a piece of code which sorts the items from the array into order the youngest first. ( 9 Marks )

a) Write a program that investigates whether a String is a palindrome i.e. a String that’s spelt the same way in reverse e.g. level, navan, etc. For convenience, you can hard code the String you want to check i.e. String s1 = new String(“navan”). ( 10 marks )

b) Describe some of the advantages of using object oriented programming over other types of programming. ( 3 marks )

c) Suggest any disadvantages for object oriented programming. ( 3 marks )

d) What is UML? ( 2 marks )

e) In the context of UML, what is a case diagram? ( 3 marks )

f) Explain what is meant by polymorphism. How does polymorphism manifests itself in java. ( 4 marks )

Write an applet which prompts a user to enter an hourly rate of pay and number of hours worked. When the button in the applet is pressed the program should calculate the total pay and display it for the user as follows:

( 25 Marks )

a) Write a method for a PrimeNumbers() class which determines if a given positive integer is a prime number. ( 8 Marks )

b) Using this method, write a program that lists all prime numbers within a given range e.g. if the range is between 1 and 12 the output might look something like the following:

1 true 2 true 3 true 4 false 5 true 6 false 7 true 8 false 9 false 10 false 11 true 12 false ( 9 Marks )

c) Write a program that determines whether a Sting is a palindrome i.e. a word or expression that spells the same way backwards as forwards e.g. navan. A sample output might look like this:

navan is a palindrome

cork is not a palindrome ( 8 Marks )

a) In Java, what is meant by association? ( 2 Marks )

b) Write a Job() class with the following attributes, constructor and methods:

attributes: responsibility, payRate, time

constructor: public Job(String responsibility, double payRate, double time)

methods: public double getPayRate() public double getTime() public String getResponsibility() ( 6 Marks )

c) Write an Employee() class with the following attributes, constructor and methods:

attributes: name, newJob

constructor: public Employee(String name, Job newJob)

methods: private String displayName() private double calculatePay() public void displayDetails() ( 6 Marks )

d) Write an example program which incorporates the above classes. ( 6 Marks )

e) In java, what is a Vector()? ( 2 Marks )

f) Suggest an advantage of using Vector() instead of an array? ( 3 Marks )