Tuesday, 22 September 2009

Java Certification Question 0101

Given the following code

class Base{}

public class MyCast extends Base{

static boolean b1=false;
static int i = -1;
static double d = 10.1;

public static void main(String argv[]){

MyCast m = new MyCast();
Base b = new Base();
//Here

}

}

Which of the following, if inserted at the comment //Here will allow the code to compile and run without error

1) b=m;
2) m=b;
3) d =i;
4) b1 =i;



Answer :

2) If multiple listeners are added to a component the events will be processed for all but with no guarantee in the order
4) You may remove as well add listeners to a component.

It ought to be fairly intuitive that a component ought to be able to have multiple listeners. After all, a text field might want to respond to both the mouse and keyboard


No comments: