< Kurs:Informatik I

T3 - Types and Expressions


1

Given the following expression:

x * 4 > y * 3 | a == b


Which bracket structure corresponds to its evaluation order?

((x * 4) >( y * 3)) | (a == b)
( x * (4 > y) * 3) | (a == b)
( x * 4) >(( y * 3) |( a == b))

2

Assume the following declarations:

int a, b, c;
boolean b1, b2;
String name, vorname;
double x, y;


Which types do the following expressions have:

1. a+b
2. b-x
3. vornamen+" "+name
4. a==b
5. b1 =(x>y) && b1


1. double 2. double 3. String 4. boolean 5. boolean
1. int 2. double 3. String 4. boolean 5. boolean
1. int 2. double 3. String 4. int 5. boolean
1. int 2. int 3. String 4. boolean 5. boolean
1. int 2. double 3. String 4. boolean 5. void

3

Which of the following are valid Java identifiers?

heute-geht-es-los
Heute.geht.es.los
heute_geht_es_los
heute geht es los
HeuteGehtEsLos
"heute geht es los"

4

Assume the following declarations:

int a, b;
char c;
boolean b1, b2;
String name, vorname;
double x, y


Which of the following expressions will cause a type error?

a*x+b
x+b2
(a+b)/x
name+b1
a+b2
name+a+vorname
a+c
(a+b)%x
name+c
x/c

5

Assume again the following declarations:

int a, b, c;
boolean b1, b2;
String name, vorname;
double x, y;


Which of the following expressions is a valid boolean expression?

a && b1
b1 && b2y>0
a>b>c
!b1 != true
a=bx>=0
!a!b2
a>bx>=0
a>b && !x
b1 && (x ==0)
(name>0)(vorname >0)

This article is issued from Wikiversity. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.