Question 35)
What will happen when you attempt to compile and run the following code
public class Borley extends Thread{
public static void main(String argv[]){
Borley b = new Borley();
b.start();
}
public void run(){
System.out.println("Running");
}
}
1) Compilation and run but no output
2) Compilation and run with the output "Running"
3) Compile time error with complaint of no Thread target
4) Compile time error with complaint of no access to Thread package
Answer to Question 35)
--------------------------------------------------------------------------------
Question 36)
Assuming any exception handling has been set up, which of the following will create an instance of the RandomAccessFile class
1) RandomAccessFile raf=new RandomAccessFile("myfile.txt","rw");
2) RandomAccessFile raf=new RandomAccessFile( new DataInputStream());
3) RandomAccessFile raf=new RandomAccessFile("myfile.txt");
4) RandomAccessFile raf=new RandomAccessFile( new File("myfile.txt"));
Answer to Question 36)
--------------------------------------------------------------------------------
Question 37)
Given the following class definition
public class Upton{
public static void main(String argv[]){
}
public void amethod(int i){}
//Here
}
Which of the following would be legal to place after the comment //Here ?
1) public int amethod(int z){}
2) public int amethod(int i,int j){return 99;}
3) protected void amethod(long l){ }
4) private void anothermethod(){}
Answer to Question 37)
--------------------------------------------------------------------------------
Question 38)
Which of the following statements are true?
1) Code must be written if the programmer wants a frame to close on selecting the system close menu
2) The default layout for a Frame is the BorderLayout Manager
3) The layout manager for a Frame cannot be changed once it has been assigned
4) The GridBagLayout manager makes extensive use of the the GridBagConstraints class.
Answer to Question 38)
--------------------------------------------------------------------------------
Question 39)
Given the following class definition
public class Droitwich{
class one{
private class two{
public void main(){
System.out.println("two");
}
}
}
}
Which of the following statements are true
1) The code will not compile because the classes are nested to more than one level
2) The code will not compile because class two is marked as private
3) The code will compile and output the string two at runtime
4) The code will compile without error
Answer to Question 39)
--------------------------------------------------------------------------------
Question 40)
Given the following code
class Base{
static int oak=99;
}
public class Doverdale extends Base{
public static void main(String argv[]){
Doverdale d = new Doverdale();
d.amethod();
}
public void amethod(){
//Here
}
}
Which of the following if placed after the comment //Here, will compile and modify the value of the variable oak?
1) super.oak=1;
2) oak=33;
3) Base.oak=22;
4) oak=50.1;
Answer to Question 40)