Summary for 1/15/04

Lecture Summary for 211 on 1/14/04

 

Review Questions

  1. How do you find the Java examples for this class?

  2. When, where, and why was Java developed?

  3. What is the difference between JDK1.3 and BlueJ?

  4. Why is Java hard for beginners?

  5. What is "boiler plate" code?

  6. Write a line of Java code that will print the message "Java is fun."

  7. What is an instance variable?

  8. What is a method?

  9. What is a constructor?

  10. What is the difference between a class and an object?

  11. Name three ways of specifying comments in Java?

  12. What are the steps to creating a Java application in BlueJ?

 

Command Line vs. User Interface Applications

 

Java Constants, Variables, and Datatypes

 

The Primitive Example

 

Practice Problems

  1. Create an integer variable and initialize it to 1.5 billion.

  2. Create a variable and initialize it to 6 billion.

  3. Create a character variable and initialize it to the upper case W character.

  4. Create a boolean variable and initialize it to false.

 

Java Operators

 

The JOptionPane Class

 

The DecimalFormat Object

 

The parseInt Method

 

Static vs. Nonstatic Methods

 

Examples of Static and Nonstatic Methods

Class Method Static?
Main main Yes
JOptionPane showInputDialog Yes
Math random Yes
Math sqrt Yes
VendingMachine depositQuarter No
VendingMachine selectCandy No
VendingMachine printStatus No
Coin flip No
DecimalFormat format No

 

Practice Problems

  1. Write a Java program that will input a temperature in Celsius, change the input string into an int, convert the temperature to Fahrenheit, and print the Fahrenheit temperature.

  2. Write a Java program that will input an integer, then output a 0 if the input is even and a 1 if the input is odd.

Here are the answers to the practice problems.