Τι θα τυπώσει ο παρακάτω κώδικας?
-SmallBean{a=5, b=500}
-SmallBean{a=1, b=3}
-RunTime Exception
-Δεν θα κάνει compile
Αιτιολογήστε το στα σχόλια
[code language=”java”]
package javaapplication1;
/**
*
* @author TENANTS\diakogiannisa
*/
public class JavaApplication1 {
SmallBean playWithThoseNumbers(final Long a, final Long b, final SmallBean sb) {
sb.setA(a);
sb.setB(b);
return sb;
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Long a = 1l;
Long b = 3l;
JavaApplication1 ja = new JavaApplication1();
SmallBean inputData = new SmallBean(50l, 500l);
SmallBean sb = ja.playWithThoseNumbers(a, b, inputData);
System.out.println(sb);
}
}
class SmallBean {
public SmallBean(Long a, Long b) {
this.a = a;
this.b = b;
}
public SmallBean() {
}
private Long a;
private Long b;
public Long getA() {
return a;
}
public void setA(Long a) {
this.a = a;
}
public Long getB() {
return b;
}
public void setB(Long b) {
this.b = b;
}
@Override
public String toString() {
return "SmallBean{" + "a=" + a + ", b=" + b + ‘}’;
}
}
[/code]