0% found this document useful (0 votes)
3 views1 page

201801examen en

The document outlines the final exam for a Programming I course, consisting of theory questions and practical programming tasks. Students are required to identify errors in a provided program, explain design concepts, and develop algorithms in Java for specific tasks involving character arrays and file manipulation. Emphasis is placed on modularity, clarity, and the use of a defined Word class in the solutions.

Uploaded by

powerpau1057yt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

201801examen en

The document outlines the final exam for a Programming I course, consisting of theory questions and practical programming tasks. Students are required to identify errors in a provided program, explain design concepts, and develop algorithms in Java for specific tasks involving character arrays and file manipulation. Emphasis is placed on modularity, clarity, and the use of a defined Word class in the solutions.

Uploaded by

powerpau1057yt
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

20302 Programming I – Final Exam. January 2018.

(Time to complete the exam: 3 hours)


1. Theory questions. (30 minutes, 2 points)
a. What is incorrect in this program that uses a Word class similar to the one we have seen during
the course. (1 point)

Program Word class


public static void main(String[] args) { public class Word {
// maximum number of words in the input text // attributes
final int MAX = 100; // constructor
Word[] words = new Word[MAX]; public Word() { /* ... */ }
System.out.println("Enter a text"); // fills an already existing word
int numWords = 0; // with the input text
for (; Word.wordsAvailable(); numWords++) { public void read() { /* ... */ }
words[numWords].read(); // can we read more words?
} public static boolean wordsAvailable() { /* ... */ }
for (int i = 0; i < numWords; i++) { // String image
System.out.println(words[i]); public String toString() { /* ... */ }
} }
}
b. Explain what is the descendent design and give an example. (1 point)

2. Develop an algorithm in Java that declares and initializes an array of 200 char, assigns a random
character between 'a' and 'z' (lowercase letters) in every position and performs this sequential process:
print the pairs of characters formed by a vowel followed by the letter 'm' and the index where the first
letter of the two letters was found. In example,

Fragment of the array of 200 char Fragment of the output of the program
… 25 26 27 28 29 30 31 32 33 … ...
a m 26
… s a m h e f m u m … u m 32
...
Modularity, clarity and explanation of the solution will be assessed. (1 hour, 3.5 points)

3. An homohemigram is defined as a word formed by two groups of letters that are exactly the same, in
other words, the first half of the word is identic to the second part. In example: bonbon, coco, meme,
chichi.
Develop a program in Java that, given a file words.txt that contains a word in each line, writes in the
file homohemigrams.txt the words of that type that can be found in the first, one in each line.
It is required to define and use the Word class and any other that is considered needed to solve the
exercise. It is forbidden to use the class String for anything else than input/output operations.
Modularity, descendent design, clarity and explanation of the solution will be assessed. (1.30 hours,
4.5 points)

You might also like