SELL — Examples

Click on the »Edit« button in one of the examples below.
— Examples in English will be provided soon. —

Playground

If-Anweisung
Gegeben sei der folgende Java-Programmausschnitt:

int x=3, y=5, z=8;
if(x > 1) {
    z = 1;
    y = 10;
}
else if(y <= 7) {
    z = 2;
}


Welchen Wert enthält Variable z nach Ausführung des Programmausschnitts?
     

  • The first line is used as headline.
  • Code is indented by tabs. It is used to draw random variables and to calculate the solution.
  • Equations are denoted in AsciiMath-syntax and can be embedded into dollar signs. Example:
    • $ sqrt(x) $ is displayed as x.
  • Text formatting is similar to Markdown. Examples:
    • A bullet point is denoted by * at the beginning of a line.
    • __bold__ is displayed bold.
  • The solution textfield is created by a hashtag # following the solution variable.
For detailed information, visit the tutorials and language specification.

If-Anweisung
Gegeben sei der folgende Java-Programmausschnitt:

int x=3, y=5, z=8;
if(x > 1) {
    z = 1;
    y = 10;
}
else if(y <= 7) {
    z = 2;
}


Welchen Wert enthält Variable z nach Ausführung des Programmausschnitts?
      

Schleifen
Gegeben sei der folgende Java-Programmausschnitt:

int a = 3, b = 0;
for(int i=0; i<5; i++)
    b += a;
System.out.println(b);


Welche Ausgabe erhalten Sie nach Ausführung?
Der Schleifenkopf könnte alternativ auch wie folgt geschrieben werden, ohne dass sich die Ausgabe ändern würde.
 for(int i=0; i++; i<5)   
 for(int i=0; i<=5; i++)   
 for(int k=0; k<5; k+=1)   
 for(int i=0; i<5; ++i)   
 for(int i=10; i<15; i++)   
      

Schleifen
Gegeben sei der folgende Java-Programmausschnitt:

int i=0, x=4;
while(i < 5) {
    x = x * i;
}
System.out.println(x);


Was passiert?
 Man erhält (für den gezeigten Ausschnitt) einen Syntaxfehler.   
 Das Programm terminiert nicht.   
 Es wird 20 ausgegeben.   
      

Schleifen
Eine zu programmierende Schleife soll mindestens einmal durchlaufen werden:
Man verwendet hierzu am besten ...
 ... eine kopfgesteuerte Schleife.   
 ... eine fußgesteuerte Schleife.   
      

Schleifen

int x = 3, y = 0;
for(int i=0; i<6; i=i+2) {
    if(x == 2)
        continue;
    if(x == 4)
        break;
    y ++;
}


Welchen Wert enthält Variable y nach Ausführung des Programmausschnitts?
      

Mehrfachauswahlen

int a = 1, b = 0;
switch(a) {
    case 0:
        b = 10;
        break;
    case 1:
        b = 20;
    default:
        b = 30;
        break;
}


Welchen Wert enthält Variable b nach Ausführung des Programmausschnitts?
Hinweis: Genau hinschauen!
      


         
Contact:  Andreas Schwenk
© 2025 TH Köln • Prof. Dr. Heiko Knospe • Andreas Schwenk, M.Sc.