JAVA and Internet Programming, Computation & Visualization
Midterm Study Guide, Mon., July, 22, 2002, 10:30-11:20AM, MS
I. Theoretical Component
- Compiled vs. interpreted languages, pros & cons.
- Structural/Procedural vs. Object-Oriented programming differences
- Applications vs. Applets
- Illustrate in a figure the process of generating and running Java
programs (compiles & interpreter, ASCII vs. bytecode representation of
- What do these acronyms stand for: JDK, API, JRE, JVM, OOP.
- A class is the basic building block of an object-oriented
language, what is the difference between a class and an object
(give some examples).
- What is the program-entry-point for a Java application? How about
for a Java applet?
- Differentiate between class and instance
members! Can we do away with one of these types?
- What is a message? What are messages used for?
- What is a state and what is a behavior of an object?
- Can a Java class extend more than 1 class? How many? Are there
differences from C++?
- What are interfaces?
- What is inheritance? Is inheritance specific to OOP languages?
- How can a Java object inherit functionality from multiple parents?
- What types of members can an object have?
- What are the Java primitive data-types?
- How is variable declaration different from its instantiation
- Are object constructors different from other member methods?
- Variable identifiers: type, scope, value, name.
- What are the conventions for naming your members (variables, constants,
- What type of iterative statements are allowed in Java?
- What type of conditional statements are allowed in Java?
- What are the differences between Character, String and
- What are the basic sub-classes of the abstract class
- What are the basic access-specifiers for classes/members?
- What is this a reference to? Why is it necessary?
- Why do we want to have member variables be accessible only through
variable-access-methods provided by the class desinger/programmer?
- Nested classes! Implicit Objects!
II. Applications Component
- Write a HelloWorldApp application that shows a window
and displays the string "Hello World".
- Write the command-lines to compile and run the application
- Convert the previous example to an applet. Include the necessary
HTML file. Why is this file needed? Can it be used to alter the behaviour/appearance
of the applet?
- Give 2 examples of defining, instantiation and usage of a
class and instance variables.
- Give examples of using messages (e.g., function calls).
- List 10 different members for a class
Rectangle, which would be necessary to provide the means
to alter the state and behavior of any object of type
- Give some examples (pseudo code) of inheritance and its importance.
- Give some examples of declaring variables that are constants, private
to the current class or accessible to all classes within the package.
- Declare and instantiate an array of integers of 15 elements
and set each element of the array equal to the index of the element. Print
out the array indices and their values one element per line?
- Define a class Circle and include
some member variables and member methods and constructors, specific to
this class, leaving the bodies of the methods empty.
- Write a complete method that takes in a Vector object myData
and computes the average of the integer values in myData
- Write the negation of the boolean statement
if ( (!p) && (q || r) ), where p, q, r are
initialized boolean variables.
- What is the binary expression 1100 & 1010 equal to?
- Write an application that reads a number as command line argument
and prints the name of the corresponding month, if the number is between
1 and 12, or prints No such month!, otherwise.
- Give 5 examples of calling methods from some commonly used objects.
How do we go about accessing object member variables?
- List 5 methods that the String class should absolutely have.
- Write a program that reads a string as a command line argument
and prints out (on the standard output stream) the string in reversed order.
- What is the result of: 145/12.5? How about 145 %30?
- Give some examples of converting numbers to strings and casting
strings as numbers.
- Declare and instantiate a JTextField variable. Set the text
to "123". Extract the text and cast it as an integer, multiply
by 2 and write it in the JTextField .
- Declare and instantiate a JButton object. Make your class
ActionListener and define the body of the actionPerformed method
so that a result of the string in the JTextField above is printed twice
in the text field.
- Define a class ComplexNumber with 2 private member variables
rE and iM (for the rEal and iMaginary part
of the complex number) and provide setRe(double newRe), setIm
(double newRe), getRe(), getIm(), public member
methods for establishing controlled access to these variables.
Last modified on
\Ivo D. Dinov, Ph.D., Departments of Statistics, Neurology &
Program in Computing, UCLA School of Medicine/