Week 02 Study Questions

1.  When your Java program is compiled, what type of file is created?  (Hint:  It is NOT machine language.)

2.  What does it mean for someone to say that a Java program is “portable”?

3.  TRUE/FALSE:  Inserting unnecessary spaces and/or blank lines could cause your Java program to malfunction.

4.   What is the difference between “syntax errors” and “logical errors”?

5.   If your program compiles and runs, but behaves incorrectly, are you probably suffering from “syntax” or “logical” errors?

6.  If Eclipse flags your code with a red mark and won’t let you compile it, are you suffering from “syntax” or “logical” errors?

7.   List the four Java primitive types that can be used to store integer values.

8.   How much memory is required to store each of the four types mentioned in the previous question?

9.  What advantage do you gain from using one of the types of integer types that requires MORE memory?

10.   List the two Java primitive types that can be used to store floating point values.

11.   How much memory is required to store each of the two types mentioned in the previous question?

12.  What advantage do you gain from using one of the floating point types that requires MORE memory?

13.  List the two Java types that are used to store values that are not numbers.

14.  Write a statement that declares a variable named counter of type int, and stores the value 182 in the variable.

15.   Write a statement that simultaneously declares three variables of type boolean, named x, y, and z.

16.  What values can a boolean variable achieve?

17.  Write a java class called “Fred”.  Put in a main method.  Have the main method store your age in a variable named age. Then main should print out a line that has your name, followed by your age.  (Use a “string literal” for your name, but use the variable to access your age.)

18.   Practice using BOTH styles for Java comments.

19.   Is the following statement valid:     int x = 34.7;

20.   Is the following statement valid:     double y = 12;

21.   Is the following statement valid:      boolean q = 17 < 25;

22.   Evaluate the following Java expression:  9 - 15 * 6 / 11 + 4

23.   Evaluate the following Java expression:  75 % 7

24.  Never forget that you should not compare two Strings with the == operator.  Suppose you have two String variables, x and y.  Give an expression that can be used to check whether or not the Strings x and y are identical.

25.  What is “concatenation”?  What operator do you use to concatenate Strings?

26.   What is the difference between System.out.print and System.out.println?

27.  Suppose you have a String variable called s.  What expression will return the number of characters in the String?

28. Give examples of "literals" of each of the following types:  String, char, long, int, float, double, boolean.

29.  What "escape sequence" would you use in a String to indicate a "new line"?