Question 51)
Given the following code what will be the output?class ValHold{
public int i = 10;
}
public class ObParm{
public static void main(String argv[]){
ObParm o = new ObParm();
o.amethod();
}
public void amethod(){
int i = 99;
ValHold v = new ValHold();
v.i=30;
another(v,i);
System.out.println(v.i);
}//End of amethod
public void another(ValHold v, int i){
i=0;
v.i = 20;
ValHold vh = new ValHold();
v = vh;
System.out.println(v.i+ " "+i);
}//End of another
}
1) 10,0, 302) 20,0,303) 20,99,304) 10,0,20
Answer
to Question 51)
--------------------------------------------------------------------------------
Question 52)
Given the following class definition, which of the following methods could be
legally placed after the comment//Here
public class Rid{
public void amethod(int i, String s){}
//Here
}
1)public void amethod(String s, int i){}2)public int amethod(int i,
String s){} 3)public void amethod(int i, String mystring){} 4) public
void Amethod(int i, String s) {}
Answer
to Question 52)
--------------------------------------------------------------------------------
Question 53)
Given the following class definition which of the following can be legally
placed after the comment line//Here ?class Base{
public Base(int i){}
}
public class MyOver extends Base{
public static void main(String arg[]){
MyOver m = new MyOver(10);
}
MyOver(int i){
super(i);
}
MyOver(String s, int i){
this(i);
//Here
}
}
1)MyOver m = new MyOver();2)super(); 3)this("Hello",10);4)Base b
= new Base(10);
Answer
to Question 53)
--------------------------------------------------------------------------------
Question 54)
Given the following class definition, which of the following statements would
be legal after the comment //Hereclass InOut{
String s= new String("Between");
public void amethod(final int iArgs){
int iam;
class Bicycle{
public void sayHello(){
//Here
}//End of bicycle class
}
}//End of amethod
public void another(){
int iOther;
}
}
1)System.out.println(s); 2) System.out.println(iOther);3)
System.out.println(iam);4) System.out.println(iArgs);
Answer
to Question 54)
--------------------------------------------------------------------------------
Question 55)
Which of the following are methods of the Thread class?
1) yield()2) sleep(long msec)3) go()4) stop()
Answer
to Question 55)
--------------------------------------------------------------------------------
Question 56)
Which of the following methods are members of the Vector class and allow you
to input a new element
1) addElement2) insert3) append4) addItem
Answer
to Question 56)
--------------------------------------------------------------------------------
Question 57)
Which of the following statements are true?
1) Adding more classes via import statements will cause a performance
overhead, only import classes you actually use.2) Under no circumstances can
a class be defined with the private modifier3) A inner class may
under some circumstances be defined with the protected modifier4) An
interface cannot be instantiated
Answer
57)
--------------------------------------------------------------------------------
Question 58)
Which of the following are correct event handling methods
1) mousePressed(MouseEvent e){}2) MousePressed(MouseClick e){}3)
functionKey(KeyPress k){}4) componentAdded(ContainerEvent e){}
Answer
58)
--------------------------------------------------------------------------------
Question 59)
Which of the following are methods of the Collection interface?1)
iterator2) isEmpty3) toArray4) setText
Answer
59)
--------------------------------------------------------------------------------
Question 60)
Which of the following best describes the use of the synhronized keyword?
1) Allows two process to run in paralell but to communicate with each
other2) Ensures only one thread at a time may access a method or
object3) Ensures that two or more processes will start and end at the same
time4) Ensures that two or more Threads will start and end at the same
time
Answer
60)