Computer Science II
Computer Science II
Spring 2009, Wednesday, 2/11/09
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 only the .class filenames found in your subdirectory cs2 _______________________________ [2]
3. Delete all files that contain temp in the name. ____________________[2]
4. Create a subdirectory in your home directory (~) called library. ___________________________[2]
5. Move all .class files in your current directory to this subdirectory library ________________________[2]
6. Change your current working directory to library directory ________________________[1]
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. Print your typescript file, 2 pages per sheet. _________________________ [1]
10. Start the visual editor on file test.java ______________________[2]
11. Compile the source file test.java ____________________________[2]
12. Run the Java program first using the filename mydata as a command line argument. __________________________________________________ [2]
13. Run the Unix program filter redirecting the file data for input and sorts output stream. Just displays results. __________________________________________________ [3]
14. What key combination designates end of input in Unix? ____
What key combination cancels a program in Unix? ____
What characters designate the parent directory? _____
What character designates the top level directory? _____ [4]
15. Give the alphabetic or punctuation character(s) in vi to perform the following actions
[8 pts]
_____ move the cursor right 1 character (1 character)
_____redo the previous action (1 char)
_____ start insertion mode (1 char)
_____ end insert mode (1non standard character)
_____ delete the current character (1 char)
_____ delete the current word (2 chars)
_____ exit and do not save the file or its changes (3 chars)
_____exit and save the file (2 chars)
16. Arrays.
[12 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 the value size-index (element 0 contains size, the last element contains 1, etc.). [6]
b. Give a Java code segment to make a full cloned copy of the array nums called numsCopy. [6]
17. Object-oriented programming design principles. (True/False)
[8 pts]
a. ____ An Abstract Data Type encapsulates a data structure organization and its operations.
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 defines methods that must be implemented by a class that then may be used by other classes.
e. ____ ADT specifications depend on the implementation language, e.g. Java.
f. ____ The information hiding principle prevents the user from seeing the implementation but the implementer knows how his/her code will be used.
g. ____ A pre-condition specifies what must be true about the inputs at the end of a method.
18. Miscellaneous Java concepts (True/False)
[10 pts]
a. _____ Each Java class should be defined in its own separate file with the extension .java but the file name can be anything.
b _____ The contents of the .class file are called bytecodes, which are independent of a particular machine’s architecture.
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 a Boolean value.
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 subclass.
i. ______ The types of int and double are not true classes for performance purposes.
j. ______ Reusability is a quality software goal in object-oriented class design.
19. Number the steps of the software development cycle (Waterfall method) from 1 to 6 in correct order.
[6 pts]
_____ Design _____ Requirements identification
_____ Testing _____ Maintenance
_____ Analysis _____ Implementation
20. Rank the algorithm complexities from "fastest" to "slowest" (increasing dominance). 1 is fastest (good, low cost) and 6 is slowest (bad, high cost).
[10 pts]
|O(n2) |O(n) |O(2n) |O(n log n) |O(1) |O(log n) |
| | | | | | |
21. 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) = 5n2+ kn + 7
_______ f(n) = n3 + 900n2 + 50k + 100
_______ f(n) = kn2 + 4k4
_______ f(n) = 8n4 +4n
22. 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.
[10 pts]
| |for(j=0; j ................
................
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