Java Reference
In-Depth Information
Given:
public class AyeAye {
int i = 40;
int j;
public AyeAye() {
setValue(i++);
}
void setValue(int inputValue) {
int i = 20;
j = i + 1;
System.out.println(“j = “ + j);
}
}
What is the value of the j variable at the time it is displayed inside the setValue()
method?
3
a. 42
b. 40
c. 21
d. 20
The answer is available on the topic's website at http://www.java21days.com. Visit the
Day 3 page and click the Certification Practice link.
Exercises
To extend your knowledge of the subjects covered today, try the following exercises:
1. Create a program that turns a birthday in MM/DD/YYYY format (such as
12/04/2007) into three individual strings.
2. Create a class with instance variables for height , weight , and depth , making each
an integer. Create a Java application that uses your new class, sets each of these
values in an object, and displays the values.
Where applicable, exercise solutions are offered on the topic's website at http://www.
java21days.com.
 
Search WWH ::




Custom Search