Computer Science II - Juniata College
Computer Science II
Spring 2005, Wednesday, 2/9/05
100 points
Name _____________________________
Explain or give the UNIX or vi commands or keystrokes to do the following tasks.
[29 pts]
1. Display all details of files found in your current directory. __________________[2]
2. Display java source files found in /academic/cs2 _________________________________ [2]
3. Create a subdirectory called proj5. ___________________________[2]
4. Move all .java files in your current directory to this subdirectory proj5 ________________________[2]
5. Delete all files that contain tmp in the name from your current directory. __________________________[2]
6. Change your current working directory up to the parent directory ________________________[2]
7. Display only the first 10 lines of the file test.java . ______________________[2]
8. Begin capturing the screen display to a file for printing later. ____________________ [1]
9. Start the visual editor on file test.java ______________________[2]
10. Compile the code in test.java ____________________________[2]
11. What keystroke cancels a program in Unix? ____
What keystroke designates end of input in Unix? ____
What character designates the current directory? _____
What characters designate the directory one level up? _____ [4]
12. Which file may contain alias commands c-shell? _________________________ [1]
13. Run the Java program prog using the file data as a command line argument. __________________________________________________[2]
14. Run the Unix program filter using the file data for input and pipe the output stream through more. __________________________________________________[3]
15. Give the keystroke(s) in vi to perform the following actions
[8 pts]
_____ move the cursor up 1 line (1 char)
_____ start insertion mode (1 char)
_____ end insert mode (1 char)
_____ repeat the previous editing operation (1 char)
_____ delete the current line (2 chars)
_____undo the previous action (1 character)
_____exit and save the file (2 chars)
_____ exit and do not save the file or its changes (3 chars)
15. Arrays.
[10 pts]
a. Give a code segment to define an integer array of 100 elements and a for loop that initializes each element to its index (element 0 contains a 0, element 9 contains a 9, etc.). [7]
b. Explain how a two-dimension array is an array of arrays. A drawing is permissible. [3]
16. Abstract Data Types. (True/False)
[5 pts]
a. ____ The ArrayList class is found in the package java.util.
b. ____ The ArrayList requires the use of wrappers in order to store ints and doubles.
c. ____ All ADTs implemented as Java classes ultimately inherit from the Object class.
d. ____ An abstract class can be used to define shared methods and instance variables inheritable by related subclasses.
e. ____ An ADT defines the data organization and its operations, but not necessarily the implementation.
17. Object-oriented programming design principles.
[8 pts]
b. A ________-condition specifies what must be true at the beginning of a method and a ____________________ specifies what must be true at the end of a method. These assertions provide a form of a contract between the ____________ and the implementer.
a. The Information Hiding Principle specifies that the user of a module is provided only the necessary information to _________ the module and that the ___________________________ is provided only the necessary information to ______________________ the module.
c. Testing a module knowing its function but not necessarily its implementation is called ___________- box testing while ___________ -box testing ensures each control path is tested in the implementation.
18. Miscellaneous Java concepts (True/False)
[10 pts]
a. _____ Each Java class should be defined in its own separate file with the extension .java and that file name must match the class name.
b _____ The contents of the .class file are called bytecodes, which are machine independent.
c. _____ Garbage collection in Java must be started by the user to recover memory from the unreferenced objects.
d. _____ The toString method that can be defined for each class is an example of an accessor.
j. _____ Protected variables are inheritable but still private to the user of the subclass.
e. _____ An iterator ensures that all elements of a collection can be sequentially accessed.
f. _____ A class that is inherited from an existing class is called a superclass.
g. _____A class is one usually composed of public instance variables and private methods.
h. _____The Exception class has the property of being throwable.
i. _____ Two strings compared by the compareTo() results in an integer.
19. Number the steps of the software development cycle (Waterfall method) from 1 to 6 in correct order.
[5 pts]
_____ Design _____ User request
_____ Analysis _____ Implementation
_____ Integration _____ Maintenance
20. We have discussed the differences in the implementations between an UnsortedStringList and SortedStringList. Describe for each of the abstract operations how the operation is best accomplished in a sorted setting and an unsorted setting
[9 pts]
|Abstract operation |For UnsortedStringLists |For SortedStringLists |
|Insert a new element into the | | |
|list | | |
| | | |
| | | |
| | | |
| | | |
|Delete the first element from | | |
|the list | | |
| | | |
| | | |
| | | |
| | | |
|Determine if an element exists | | |
|in the list | | |
| | | |
| | | |
| | | |
21. Below is a segment of code similar from class and your project. Assume classes Date is a class that holds the day, month and year along with a String description. A constructor can take three integers and a String, or another date instance and a string. IncDate inherits from Date and adds the increment method that advances the day by one. In both cases the toString() function prints the date in mo/day/yr format and a function getDescription() returns the description string.
[16 pts]
0 try {
1 IncDate [] events;
2 events = new IncDate[10];
3 events[0] = new IncDate (1,17,2005, “Classes start”);
4 events[1] = new IncDate (2,2,2005, “Groundhog Day”);
5
6 IncDate today = new IncDate(2,9,2005,”CS 240 Exam 1”);
7 IncDate tomorrow = new IncDate(today,”Work on Program 3”);
8 tomorrow.increment();
9 events[2] = today;
10 events[3] = tomorrow;
11 events[4] = new IncDate (5,4,2005,”Reading Day”);
12 } catch (Exception e) {
13 System.out.println(“Error in initialization: “+e.getMessage());
14 }
15 for(i=0; i ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- igcse computer science workbooks pdf
- igcse computer science workbook
- igcse computer science workbook answer
- igcse computer science coursebook pdf
- computer science people
- what is computer science like
- computer science revision
- igcse computer science revision notes
- college computer science project ideas
- ideas for computer science project
- computer science projects for students
- computer science final project