ECE309Spring2010Lecture4

ECE309Spring2010Lecture4 - ECE309 - Lecture 4 - Spring 2010...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE309 - Lecture 4 - Spring 2010 - Thursday January 21
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Lab2 TherapistGUI is due tonight Today's topics prepare the student to program lab 3 RemoteTherapist 1. In-class exercise: Grade homework papers "Draw a storage map of lab 1 execution". 2. How is everyone doing on Lab 2? What are your GUI questions? 3. "Overloaded" methods (methods with same name) 4. In-class exercise: Code and run SimpleClient and SimpleServer 5. A "call" is a branch (probably delayed to a future class) "Overloaded" methods Two methods in a class can have the same name in Java, and this is no problem - as long as the parameters of the two versions of the method are different. This is because the Java compiler considers the method "signature" to be the method name PLUS the parameters. Thus the method public int add(int x, int y) { return x + y; } is known as "add-int-int" to the compiler. And the method public int add(int x, int y, int z) { return x + y + z;
Background image of page 2
} is known to the compiler as "add-int-int-int" . And there is no confusion when programs call these methods. If a program says int sum = add(5,6); the compiler sees that two parameters are provided, and that version of the add() method is called. And if a program says int sum = add(a,b,c); the compiler sees three parameters and calls that version of the add() method. (And if the compiler sees add(q,r,5,9) it knows this is an error because there is no version of the add() method that takes 4 parameters.) Just a different return type is not sufficient to "overload" a method. And any difference in the parameters - number or type - qualifies for overloading. So, "overloading" method names in a class is common. And it is particularly common in the constructor method. This provides ways to load a program and pass it different amounts and types of information in parameters. IN-CLASS EXERCISE: Draw a storage map of lab 1 during execution 1. Draw the JVM on a piece of paper with blank storage areas STATIC and HEAP (dynamic storage). Also draw a blank rectangle to represent the STACK storage area in the O/S area of memory. 2. Look at your lab1 code. For each statement, in exeution order, draw
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/25/2010 for the course ECE 309 taught by Professor Bowman during the Spring '09 term at N.C. State.

Page1 / 7

ECE309Spring2010Lecture4 - ECE309 - Lecture 4 - Spring 2010...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online