AP Computer Science A / Mr. Hansen |
Name: _______________________________ |
9/26/2012 |
Test #1 (100 points): Lessons 1-15 plus Class
Discussions
Part I: Biographies
Write
a few meaningful words about each famous computer scientist.
1. Claude
Shannon
2.
Grace Hopper
3.
Dennis Ritchie
4.
Alan Turing
Part II: Hex
5.
Add 0x5A and 0x9C, and give the answer in hex. Show work.
6.
Repeat problem 5, except this time showing both addends in decimal (base 10), as
well as the final answer in decimal. Warning:
Remember to interpret any hex value with a lead digit of 8 or above as being a
negative number in 2’s complement notation. Show work.
7.
In the following data stream, how many bytes are there? ___
Words? ___ Dwords?
___
0x419085398390599F98A98934320000A0
8.
A “nybble” is half a byte. (Ba-dump ching.) How many
hex digits are in a nybble? ___
Part III: Head-Scratchers
9.
A large number of data items, stored as int values in
an array, refer to times in military format. For example, 0015 is 15 minutes
after midnight, 0820 is 8:20 a.m., 1335 is 1:35 p.m., and 2319 is 11:19 p.m. Write a single line
of Java code that could be embedded within a loop so that each data item is
replaced by its value considering only the minutes after the hour. In the
examples, only 15, 20, 35, and 19 would be saved. Use x to denote the value being updated. Don’t worry about array
indexing.
10.
Suppose that in the year 2058, it becomes necessary to expand the pool of IP addresses
yet again, from “dotted quads” (today) to “double-byte octets” (IPv6, which is
in progress) to “dozens” (IPv12, imaginary). In other words, each IP address
will consist of twelve (12) 16-bit words of data in this hypothetical future
world. How many IP addresses will then be possible? Give answer (exact) in
exponential notation as well as to an approximate power of 10.
11.
Approximately how much storage would 8 billion arrays of ints
require, if each array has 1 million entries in it? Remember, an int is 4 bytes. Use the most appropriate unit for your
answer.
Mini-Project for Test #1
Write a complete Java class (all lines, including the public static void stuff) to implement the following requirements:
1. Your program should declare and initialize a string-type variable called blorg that consists of a sentence (of your choosing) that contains all the letters of the alphabet at least once.
2. The blorg variable must begin with a capital letter and must end with a period. Within the sentence, a mix of upper and lower case is required.
3. Your program should determine the length of blorg. If blorg has an odd number of characters, write logic that determines that, and the program should then pad blorg with an extra space in order to make the length even. If blorg already has an even number of letters, write logic that determines that and prints a message saying so.
4. For the first half of the blorg string, use a for loop. For the second half, use a while loop. The logic of the loop is as described below.
5. Within the loop, use at least one if statement (for the for loop) and at least one switch statement (for the while loop) to classify each character as a vowel, a consonant, a semiconsonant (in the case of y), or neither (in the case of punctuation and spaces). Print, on a separate line for each character, the character, its ASCII code, and a short statement of its classification.