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

Thursday, January 8, 2009

Does Every Object in java Have a hashCode() metod Which of the following statements are true?

Answers:

1:By default every object has a hashCode method
2:a correct hashCode method must return a positive int value
3:a hashCode method must return the same value each and every time it is invoked
4:The hashCode method of an object can return any primitive integral type

Does Every object in java Have a hashCode() method

Tuesday, January 6, 2009

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

import java.io.*;
interface mander{
public void mander()throws Exception;
}

public class Wolvespoly implements mander{
public static void main(String argv[]){
Wolvespoly wp = new Wolvespoly();
}
private Wolvespoly(){
try{
mander();
}catch (Exception e ){
System.out.println(e.getMessage());
}
}
public native void mander() throws IOException;
}



Answers:

1:Compile time error, a constructor cannot be marked as private
2:Compile time error, native methods cannot throw exceptions
3:Compile time error, a method implemented as part of an interface implementation cannot throw exceptions not thrown in the interface version.
4:Compilation without error

Monday, January 5, 2009

What is a BitSet Collection

Answers:

1:A class that contains groups of unique sequences of bits
2:A method for flipping individual bits in instance of a primitive type
3:An array of boolean primitives that indicate zeros or ones
4:A collection for storing bits as on-off information, like a vector of bits

Sunday, January 4, 2009

Can we call a private cunstructor of super class directelyWhat will happen when you attempt to compile and run the following code?

class Vict{
private Vict(){
System.out.print("Vict");
}
}

public class BLBeck extends Vict{
public static void main(String argv[]){
new BLBeck();
}

BLBeck(){
System.out.print("BLBeck");
}
}



1:Compilation and output of "BLBeck"
2:Compilation and output of "BLBeckVict"
3:Compilation and output of "VictBLBeck"
4:Compile time error