Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
- Question: What are the data types of the following expressions, assuming that
i
's type isint
?Answer:i > 0 i = 0 i++ (float)i i == 0 "aString" + ii > 0 [boolean] i = 0 [int] i++ [int] (float)i [float] i == 0 [boolean] "aString" + i [String]- Consider the following expression:
i--%5>0
- Question: What is the result of the expression, assuming that the value of
i
is initially 10?
Answer:false
.- Question: Modify the expression so that it has the same result but is easier for programmers to read.
Answer:(i-- % 5) > 0
- Exercise: Write a program to confirm your answers to Questions 2a and 2b.
Solution:OperatorEx
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2004 Sun Microsystems, Inc. All rights reserved.