IC211 Spring AY 2020
Name (Last, First): ____________________________________________________ Alpha: _____________________
Describe help received: _________________________________________________________________
HWEX1.java | Rat.java |
Identify each of the following as either primitive, an array-reference or a class-reference: args __________________ subj1 __________________ sc __________________ nm __________________ wt __________________ wtInGrams __________________ r __________________ r.name __________________ r.weight __________________ |
|
|
Rat
are created when this program is run?
How many instances of class String
are created
when the function read()
is called, assuming the
user inputs name & weight properly.
Explain your answers! [Note: "instance" is a technical term.
Read the notes!]
|
How would you call the function fact to compute 15 factorial
from the main function of another .java file (assume it is
HW.java)? If you run the program from HW.java (i.e. give the
command java HW ), how does the JVM know where to
find the code for the fact function?
|
public class Mid {
public String alpha;
public String firstName;
public String lastName;
public int company;
}
Then write a program entitled HW3.java with the following attributes:
An example run:
~/$ java HW3 How many mids? 3 Alpha? 160006 First name? George Last name? Finklehoffer Company? 3 Alpha? 160012 First name? John Last name? Jingleheimer-Smith Company? 4 Alpha? 160018 First name? Sterling Last name? Hotchkiss Company? 3 What company would you like to print out? 3 160006 Finklehoffer George 3 160018 Hotchkiss Sterling 3
Your input and output should be exactly as it is above.
codeprint HW3.java Mid.java