September 11, 2007

Java Objective Questions - 4

31. when two or more objects are added as listners for the same event, which listener is first invoked to handle the event?
a. the first object that was added as a listener
b. the last object that was added as a listener
c. there is no way to determine which listener will be invoked first.(*)
it is impossible to have more than one listener for a given event.


32. which of the following are true?
a. a reference to an array can be cast to a reference to an object(*)
b. a reference to an array can be cast to a reference to a cloneable(*)
c. a reference to an array can be cast to a reference to a string
d. none of the above


33. which layout is used to layout the components of a container in a grid where each row and column are the same size?
a. gridlayout
b. null layout
c. gridbaglayout
d. gridbagconstraintlayout


34. what is the output of the following program?
class outer {
string s = "outer";
public static void main(string args[]) {
new outer().new Inner();
}
outer() {
system.out.prints(s);
}
class inner {
string s = "inner";
inner() {
system.out.print(s);
}
}
}
a. outer
b. inner
c. outerinner(*)
d. innerouter


35. what is the result of the expression 5.4 + "3.2" ?
a. the double 8.6
b. the string 8.6
c. the long value 8
d. the string 5.43.2(*)


36. which are true about the container class?
a. the validate() method is used to cause a container to be laid out and redisplayed (*)
b. the add() method is used to add a component to a container (*)
c. the getborder() method returns information about a containers insets
d. the getcomponent() method is used to access a component that is contained in a container (*)


37. which of the following are true about this method declaration?
void mymethod(string s) { }
a. mymethod() is static
b. mymethod does not return a value(*)
c. mymethod is abstract
d. mymethod may not be accessed outside of a package in which it is declared(*)


38. which lines of output are displayed by the following program?
class question{
public static void main(string[] args) {
for(int i=0;i<10;i++)>
try {
try {
if (i%3==0) throw new Exception("E0");
system.out.println(i);
}
catch(exception inner) {
i *=2;
if(i%3==0) throw new exception("E1");
} finally {
++i;
}
}
catch(exception outer) {
i+=3;
} finally {
--i;
}
}
}
}
a. 4(*)
b. 5(*)
c. 6
d. 7
e. 8
f. 9

39. if you run the following program, what lines would be included in its output?
class question{
public static void main(string args[]) {
int i,j;
for(i=0,j=0;i+j<20;++i,j+=i--)>
system.out.println(i+j);
}
}
}
a. 5(*)
b. 8(*)
c. 13(*)
d. the program cannot be compiled because the for statement's syntax is incorrect.

40. which of the following are direct or indirect subclasses of component?
a. button(*)
b. label(*)
c. checkboxmenuitem
d. toolbar
e. frame(*)

No comments:

Post a Comment