OOPS.................

Friday, January 23, 2009

You want to create an instance of the java.util.Vector class that will only accept elements of type String. Which of the following lines of code will

Answers:

1 java.util.Vector v = new java.util.Vector();
2 java.util.Vector v = new java.util.Vector();
3 java.util.Vector v = new java.util.Vector();
4 java.util.Vector v = new java.util.Vector();

Tuesday, January 20, 2009

What will happen when you attempt to compile and run the following code?

abstract class Hall{
public abstract void getFireStation();
}

public class Haddon extends Hall{

public static void main(String argv[]){
new Haddon().getFireStation();
}
public synchronized void getFireStation(){
System.out.print("opposite");
}
}

Answers:
1:Compile time error, synchronized can only be used in a class that extends Thread
2:Compile time error, malformed method getFireStation in class Hall.
3:Compilation and output of opposite at runtime
4:Compile time error, code within main method is incorrect.