Hi everybody,I have java exam tomorrow and one of the question is going to be tracing code,unfortunately I am not vary good at that.My question is if anybody knows web site on the net with similar questions and answers
Thanks
yesterday the professor give us this example
public class A {
private int a;
public A(){
a=1;
}
public A(int a){
this.a=(a>10)?10:a;
}
public String toString(){
return "a="+a;
}
}
public class B {
public A a;
public int b;
public B(){
a=new A();
b=2;
}
public B(int b,A a){
this();
b++;
}
public String toString(){
return "b=" + b+ "\" a+\""+a;
}
}
public class C {
public static void main(String[] args) {
B b=new B(4, null); //Iam not sure about the null here
System.out.println(b);
A a=new A(2);
System.out.println(a+b); //And I am not sure about the a+b
}
}
The result of the trace was a=2b=2"a="a=1