These exercises explore details of the language and provide practice
at writing applets and applications. You can use the Starter_App1.java
or Starter_Applet1.java
frameworks to create application or applets to carry out the exercises.
- Create a program to practice creating strings
for printing out numerical values.
Write code to print
- Example values of all 8 primitive types.
- Create a variable such as x, set it to value, and then use
the "+" append operator to print out the value in
an equation as in "x=3".
- Create 9 integer variables and assign each to a particular
value. Then print the variables out in a matrix of 3 rows
by 3 columns.
- What will be the the values of i,j,k
after the following statements labeled 1, 2, 3 and 4? Write a
program to test your predictions.:
int i = 1;
int j= 3;
int k;
k = j-- + ++i; // 1
i = 1; j = 3;
k = ++i + j--; // 2
j = 3;
k = j-- + ++j; // 3
j = 3;
k = --j + j++; // 4
- Predict what the output of the following code snippet will be
and then test your prediction with a program
int j=0;
int i=1;
for(; i < 2; i++) j++;
System.out.println("i= "+ i + " j= "+j);
i=0;
j=5;
do{
j--;
} while( (i++) < 5);
System.out.println("i= "+ i + " j= "+j);
j=5; i=0;
while( (i++) < 5){
j--;
}
System.out.println("i= "+ i + " j= "+j);
References & Web Resources
Latest update: Dec.11.2003
|