Warning: mysql_real_escape_string(): No such file or directory in /customers/webs/271605/www/volkersfreunde/wp-content/plugins/statpress/statpress.php on line 1191 Warning: mysql_real_escape_string(): A link to the server could not be established in /customers/webs/271605/www/volkersfreunde/wp-content/plugins/statpress/statpress.php on line 1191 Warning: mysql_real_escape_string(): No such file or directory in /customers/webs/271605/www/volkersfreunde/wp-content/plugins/statpress/statpress.php on line 1194 Warning: mysql_real_escape_string(): A link to the server could not be established in /customers/webs/271605/www/volkersfreunde/wp-content/plugins/statpress/statpress.php on line 1194 Warning: mysql_real_escape_string(): No such file or directory in /customers/webs/271605/www/volkersfreunde/wp-content/plugins/statpress/statpress.php on line 1197 Warning: mysql_real_escape_string(): A link to the server could not be established in /customers/webs/271605/www/volkersfreunde/wp-content/plugins/statpress/statpress.php on line 1197 Rätsel für die Semesterferien » volkersfreunde

Rätsel für die Semesterferien

Nehmt euch mal 10 Minuten oder einen Tag oder die ganzen Semesterferien und versucht zu ergründen was dieses kleine JAVA Programm in die Konsole schreibt. Kommt im Original von einem Übungsblatt von der Humbold Uni, ich hab es noch etwas gepimpt damit es noch verwirrender wird.Viel Spaß…

Vorschläge bitte als Kommentar!!! Nicht Kompilieren!!! Die Datei ist in diesem Zustand zu 100% lauffähig und führt zu einem eineindeutigen Ergebniss!!!
Vererbung.java:

class Base implements IBase{
String s = “-“;
public void print(long n) {
while (n– >= 0) {
print(s);
}
}
public void print(String s) {
System.out.println(s);
}

public void printlt() {
print(s);
}

}

class Derived extends Base {
String s = “.”;
public void print(String s) {
super.print(s);
super.print(this.s);
}
}
interface IBase{
String s = “+”;
void print(long n) ;
void print(String s);
void printlt();
}

interface IDerived{
String s = “*”;
void print(long n) ;
void print(String s);
void printlt();
}

public class Vererbung {

static String s = “#”;

public void print(long n) {
while (n– >= -1) {
print(s);
}
}
public void print(String s) {
System.out.print(s);
}

public void printlt() {
print(s);
}

public static void main(String args[]) {
Base b = new Derived();
b.print(“.”); //
b.print(2); //
b.s=”-“; //
b.printlt(); //
System.out.println(“-“); //
}
}

class Base implements IBase{
String s = “-“;
public void print(long n) {
while (n– >= 0) {
print(s);
}
}
public void print(String s) {
System.out.println(s);
}

public void printlt() {
print(s);
}

}

class Derived extends Base {
String s = “.”;
public void print(String s) {
super.print(s);
super.print(this.s);
}
}
interface IBase{
String s = “+”;
void print(long n) ;
void print(String s);
void printlt();
}

interface IDerived{
String s = “*”;
void print(long n) ;
void print(String s);
void printlt();
}

public class Vererbung {

static String s = “#”;

public void print(long n) {
while (n– >= -1) {
print(s);
}
}
public void print(String s) {
System.out.print(s);
}

public void printlt() {
print(s);
}

public static void main(String args[]) {
Base b = new Derived();
b.print(“.”); //
b.print(2); //
b.s=”-“; //
b.printlt(); //
System.out.println(“-“); //
}
}

Kommentare sind geschlossen.