Download Homework 2

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
Homework 4
(1 pt each)
Express the math expression “x = y” in Java.
Express the math expression “x<y<z” in Java.
Express the math expression “x<y or z<y” in Java.
Is there anything wrong with the code? If so, explain.
int a;
If (true)
a =1;
5. Define (that is, give the definition of) the Java operator &&.
6. Define (that is, give the definition of) the Java operator ||.
7. What is the value of (a>b) || (a<b) && (!true)? (Suppose a and b hold 1 and 2,
respectively.)
8. What is the output of the following code?
a=1; b=2;
if (b>a)
System.out.println(“b>a”);
else
System.out.println(“b<a”);
System.out.println(“or b=a”);
9. Is there anything wrong with the code? If so, explain.
int a;
int b;
boolean c;
a=1; b=2; c=a>b;
if (c)
a=2;
10. Is there anything wrong with the code? If so, explain.
public class T
{
public static void main(String args[]);
{
System.out.println(“abc”);
}
}
1.
2.
3.
4.
Related documents