The JavaTM Tutorial
Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Trail: Learning the Java Language
Lesson: Language Basics

Questions and Exercises: Expressions, Statements, and Blocks

Questions

  1. What are the data types of the following expressions, assuming that i's type is int?
    i > 0
    i = 0
    i++
    (float)i
    i == 0
    "aString" + i
    
  2. Consider the following expression:
    i--%5>0
    
    1. What is the result of the expression, assuming that the value of i is initially 10?
    2. Modify the expression so that it has the same result but is easier for programmers to read.

Exercises

  1. Write a program to confirm your answers to Questions 2a and 2b.
Check your answers. (in the Learning the Java Language trail)

Previous Page Lesson Contents Next Page Start of Tutorial > Start of Trail > Start of Lesson Search
Feedback Form

Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.