SE 450 Section 103 Fall 2001/2002
Midterm Review
- Midterm for section 103 is Tues. Oct 16, 6:15pm to 9:15pm.
Review of Topics Covered
- Basic UML Diagrams (Chapter 1 in Jia)
- Basic Java (Chapter 2 in Jia)
- Java development environment: files, tools
- compilation
- virtual machine and platform independence
- html-page and applet-tag.
- Java language (Sections 3.1 - 3.4, 4.1 - 4.3 in Jia)
- Primitive data types
- Operators
- Reference Types
- Arrays
- Control Flow
- String and StringBuffer
- Wrapper Classes
- Exceptions
- Classes
- Syntax of class, method, and field declaration
- Initialization
- Explicit
- Default
- Constructors
- Static Initialization Block
- this pointer
- public, protected, private
- Static fields and methods
- Invoking methods
- Extending classes (Inheritance)
- Constructors
- Polymorphism
- Casting (Up and Down)
- Overriding methods
- Interfaces and abstract classes
- Applets
- Applet methods: init, start, stop, paint, update
- Animation Applets (Section 4.6 in Jia)
- How is animation is achieved? You do not have to know the detials of the
threading just that it is there and how it works.
- The role of the paint method
- How to implement double buffering (off screen images and the update() method)
- Graphics class (Section 4.6 in Jia)
- draw methods (e.g., drawString, drawRect)
- drawing images
- FontMetrics class (Section 4.6 in Jia)
- AWT/Swing (Section 6.3 in Jia)
- What are they?
- Component vs container
- Widgets/Containers
- Button
- Choice
- Label
- Panel
- Frame
- Dialog
- Layout Managers
- FlowLayout
- GridLayout
- BorderLayout
- Nesting Layout Managers
- Event handling
- How does it work? Subscriber model
- What are the parts? XYZEvent, XYZListener, XYZAdapter
- Button (ActionEvent/ActionListener)
- Choice (ItemEvent/ItemListener)
- Frame (WindowEvent/WindowListener/WindowAdapter)
Midterm Review Problems
- Explain why main is a static method (for apps)
while applet methods (init, start, ... )
are not static.
answer
- What will this code print? Explain your answer.
String s1 = "abc";
String s2 = new String("abc");
String s3 = s1;
if (s1 == s2) System.out.println("s1 == s2");
if (s1 == s3) System.out.println("s1 == s3");
How can we test that s1 and s2 are equal?
answer
- What will this code print? Explain your answer.
StringBuffer s1 = new StringBuffer("abcde"),
s2 = s1;
s2.setCharAt(2,'z');
System.out.println(s1);
System.out.println(s2);
answer
- What output does this app produce? Explain your answer.
public class A {
public static void main(String[ ] s) {
B var1 = new C();
B var2 = new B(1);
System.out.println(var1);
System.out.println(var2);
}
}
class B {
private int b;
public B(int b) {
this.b = b; }
public String toString() {
return "B: " + b;
}
}
class C extends B {
private int c;
public C() {
super(1);
this.c = 3; }
public String toString() {
return "C: " + c;
}
answer
- Write an applet that places a button and a label on the screen.
The button should sit on the top of the applet and the label should be
at the bottom of the applet.
When the user clicks the button (labeled "Click Me!"), the text in the
label changes from "Nothing Yet!!!" to "Clicked!!".
Here is an example.
answer