The code defines a ListEvenNumbers class with a main method. It uses a for loop to iterate from 1 to a limit of 50, and prints any numbers that are even (where i % 2 == 0) to the console. The output printed would be all even numbers from 2 to 50.
14. public class VariablesSample {
public static void main(String[] args) {
byte b;
short s;
int i;
long l;
char c;
float f;
double d;
b = Byte.MIN_VALUE;
s = Short.MIN_VALUE;
i = Integer.MIN_VALUE;
l = Long.MIN_VALUE;
c = (int)Character.MIN_VALUE;
f = Float.MIN_VALUE;
d = Double.MIN_VALUE;
System.out.println(b);
System.out.println(s);
System.out.println(i);
System.out.println(l);
System.out.println((int)c);
System.out.println(f);
System.out.println(d);
}
}
2011 10 3
17. public class BooleanSample {
public static void main(String[] args) {
boolean t = true;
boolean f = false;
if( t == true ){
System.out.println("t is true!");
}else{
System.out.println("t is false!");
}
if( f == true ){
System.out.println("f is true!");
}else{
System.out.println("f is false!");
}
boolean isTtrue = ( t == true);
System.out.println("(t == true) is " + isTtrue);
}
}
2011 10 3