Computer Science II - Juniata College
Computer Science II
Spring 2007, Wednesday, 2/7/07
100 points
Name _____________________________
Explain or give the UNIX or vi commands or keystrokes to do the following tasks.
[28 pts]
1. Display all filenames (including hidden ones) found in your current directory. __________________[2]
2. Display java source files found in your subdirectory cs2 _______________________________ [2]
3. Create a subdirectory in your home directory called projects. ___________________________[2]
4. Move all .java files in your home directory to this subdirectory projects ________________________[2]
5. Delete all files that contain tmp anywhere in the name from your home directory. ____________________[2]
6. Change your current working directory up to the parent directory ________________________[1]
7. Display only the last 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 designates end of input in Unix? ____
What keystroke cancels a program in Unix? ____
What character designates the current directory? _____
What keystroke erases the current input line? _____ [4]
12. Print your typescript file, 2 pages per sheet. _________________________ [1]
13. Run the Java program first using the filename mydata as a command line argument. __________________________________________________ [2]
14. Run the Unix program filter redirecting the file data for input and sorts output stream. Just displays results. __________________________________________________ [3]
15. Give the keystroke(s) in vi to perform the following actions
[8 pts]
_____ move the cursor down 1 line (1 character)
_____undo the previous action (1 char)
_____ delete the current character (1 char)
_____ start insertion mode (1 char)
_____ end insert mode (1 char)
_____ delete the current line (2 chars)
_____ exit and do not save the file or its changes (3 chars)
_____exit and save the file (2 chars)
16. Arrays.
[7 pts]
a. Give a Java code segment to define an integer array nums of size elements and use a for loop to initialize each element to its index (element 0 contains a 0, element 9 contains a 9, etc.). [4]
b. List the steps to make a filled array larger. [3]
17. Abstract Data Types. (True/False)
[5 pts]
a. ____ An ADT defines the data organization, its operations as well as the implementation.
b. ____ All ADTs implemented as Java classes ultimately inherit from the Object class.
c. ____ An abstract class can be used to define shared methods and instance variables inheritable by related subclasses.
d. ____ An interface is another name for an abstract class.
e. ____ ADT specifications depend on the implementation language, e.g. Java.
18. Object-oriented programming design principles.
[6 pts]
a. The Information Hiding Principle specifies that the implementer of a module is provided only the necessary information to _______________ the module and that the ______________ is provided only the necessary information to use the module.
b. A ________-condition specifies what must be true about the inputs at the beginning of a method and a ____________________ specifies what must be true at the end of a method, if the _______-condition holds. These assertions provide a form of a contract between the ____________ and the implementer.
19. 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 dependent on a particular machine.
c. _____ Garbage collection in Java is the automatic recovery of memory from inaccessible objects.
d. _____ The toString method that should be defined for each class is an example of an accessor.
e. _____ The toString method is an example of a method that is inherited but can be overridden.
f. _____ Two strings compared by the compareTo() results in an integer..
g. _____ An iterator ensures that all elements of a collection can be accessed in some order.
h. _____ The class that extends an existing class is called the superclass.
i. _____ The primitive types of int and double are examples where the variable refers or points to the value.
j. _____Reusability is a quality software goal in object-oriented class design.
20. Number the steps of the software development cycle (Waterfall method) from 1 to 6 in correct order.
[5 pts]
_____ Testing _____ Maintenance
_____ Design _____ Requirements identification
_____ Analysis _____ Implementation
21. Rank the algorithm complexities from "fastest" to "slowest" (increasing dominance). 1 is fastest (good, low cost) and 6 is slowest (bad, high cost).
[5 pts]
|O(2n) |O(n) |O(n2) |O(log n) |O(1) |O(n2 log n) |
| | | | | | |
22. For each of the cost functions below give the “best” big-O equivalence where n is the data set size and k is some constant not related to the size of data.
[8 pts]
_______ f(n) = 2n3 + 9n2 + 50n + 100
_______ f(n) = 17 + kn + 5n2
_______ f(n) = kn + 4k4
_______ f(n) = 8n8 +2n
23. Estimate the running times using the big-O notation for each of these code segments. The size of the data set is n. Assume all variables are integer.
[8 pts]
| |for(j=n; j>0; j--){ |
| |// 3 assignments |
|____________ |} |
| |for (i=1; 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