Review
questions for the final
True
or False:
- The H in HTML stands for
Header information. ( True / False )?
- The HTML tag <LI> is
used to indicate the start of large italic text. ( True / False
)?
- In object-oriented programming,
methods provide the functionality ( True / False
)?
- Using the "binary
search" guessing strategy discussed in the notes and in class, we can
find any number between 0 and 100 in 2 guesses ( True/False )?
- Text can read from the user
and written to the screen in an applet using a TextField ( True/False
)?
- We want to connect 100
computers using ethernets that can connect 4 computers together. If each
computer has 2 network interfaces, we can connect all of the computers
with 10 networks ( True/False )?
- The if statement
allows a program to do or not do something depending on the answer to the
if clause ( True/False )?
- A good password should use
long words in the dictionary. ( True/False )?
- Public Key Encryption uses
the same key for both encryption and decryption. ( True/False
)?
- A recursive algorithm should
have some sort of base case where the solution can be given without any
further recursive calls. ( True/False )?
- You need to add an array in
the init method. (True/False)
Random
quick questions:
- What do the import lines do
at the beginning of every java program?
- What method gets called when
the user clicks a button?
- What is wrong with the
following statement (imagining that s has already been declared as a
String)? s.setText(hello
world)
- How do you declare an array?
- What values can a Boolean
have?
- What is the purpose of the
following line in an actionPerformed function? Cause
event = e.getSource();
String
manipulation:
- Write a subroutine
that returns the 3 middle letters of a word with an odd number of
letters, or the 2 middle letter of a word with an even number of words.
- Write a subroutine
that will take in a string and return a string with the letters backwards. (example: if you
pass it in “hell” it will return “lleh”)
Grammar:
- Show how to parse the
following Java statement:
2. total = freq + 1;
Be
sure to show every step and give the number of each rule that you are using.
Here
are the rules you may use
- <name> ==> any
string of alphanumeric symbols that begins with a letter
- <statement>
==> <name> = <expression> ;
- <statement>
==> <name> = new <class>(<arguments>);
- <statement>
==> <name>.<method>(<arguments>) |
<method>(<arguments>) ;
- <arguments> ==
possibly empty list of <expression>s separated by commas
- <expression>
==> <string-expression> | <int-expression> |
<oth-expression>
- <string-expression>
==> <string-expression> + <string-expression>
- <string-expression>
==> <string>
- <string> ==>
" any sequence of characters "
- <string> ==>
<name>
- <int-expression>
==> <name>
- <int-expression>
==> <int-expression> <op> <int-expression>
- <int-expression>
==> <pos-int> | - <pos-int>
- <pos-int> ==>
any sequence of digits
15. <op> ==>
+ | - | * | / | %
Recursion:
- The sum of N
numbers in an array can be computed as follows: Add the first N-1
numbers, and then add that sum to the last number. Use this method to
write a recursive function for summing an array. Your solution
should NOT involve a while loop.
Graphics:
- Write the code to draw a red
triangle with vertices (20,20), (110, 20), and (65, 80). Assume that
everything has been declared and is ready to go. This should take four
lines of code. Assume the graphics class you are working with is named g.
Binary:
- Find the decimal forms of
following binary numbers:
- 01000001
- 11111111
- Find binary forms of the
following decimal numbers:
- 15
b. 7
Running
time:
- Assume we have yet another
program which we run for several small values of N. We notice that every time
we increase N by one, it takes 10 times as long to run. Circle those of
the following terms that we might reasonably use to describe the behavior
of the program and it's underlying algorithm.
polynomial exponential intractable logarithmic difficult-for-computers made-for-computers
- Assume the information in a
telephone book has been placed in a computer memory, alphabetized like in
a real phone book. We would like to search for a name. Which algorithmic
behavior could we expect from a well written search program using a binary
search? (N is the number of entries in the phone book.)
- (Logarithmic time (t
= C * log N))
- Quadratic time (t = C
* N2 )
- Linear time (t = C *
N)