1.classPerson{publicPerson(){System.out.println("hello");}publicPerson(Strings){this();System.out.println("Iam"+s);}}publicclassWhoextendsPerson{publicWho(){this("IamTony...
1.
class Person{
public Person(){
System.out.println("hello");
}
public Person(String s){
this();
System.out.println("I am "+s);
}
}
public class Who extends Person{
public Who(){
this("I am Tony");
}
public Who(String s){
super(s);
System.out.println("How do you do?");
}
public static void main(String args[]){
Who w = new Who("Tom");
}
}
2.
public class Test{
public static void main(String args[]){
int a = 1,b=2;
String str = “hello”;
System.out.println(str+a+b);
System.out.println(a+b+str);
}
}
3.
class FatherTest {
public FatherTest( ){
System.out.println(“hello”);;
}
public FatherTest(String s) {
this( );
System.out.println(“hello,”+s);;
}
}
class Test extends FatherTest {
public Test(String s) {
super(s) ;
System.out.println(“how are you,”+s);
}
public static void main(String[] args) {
Test t = new Test(“Tom”) ;
}
}
展开