q-1)
=====
import java.io.*;
class Super
{
int methodOne( int a, long b ) throws IOException
{ // code that performs some calculations
}
float methodTwo( char a, int b )
{ // code that performs other calculations
}
}
public class Sub extends Super
{
}
which of the following are legal method declarations to
add to the class Sub?
Assume that each method is the only one being added.
a) public static void main(
String args[] ){}
b) float methodTwo(){}
c) long methodOne( int c, long d ){}
d) int methodOne( int c, long d ) throws ArithmeticException{}
e) int methodOne( int c, long d ) throws FileNotFoundException{}
the answer given are ---> a,b,e
but according to me 'd' is also valid method if we don't
declare 'e' in sub class so in this case we can choose
either d or e.
so pl.tell me the right answers and correct me if wrong
q-2)
=====
If raf is a RandomAccessFile, what is the result of compiling
and executing the following code?
raf.seek( raf.length() );
a) The code will not compile.
b) An IOException will be thrown.
c) The file pointer will be positioned immediately before the
last character of the file.
d) The file pointer will be positioned immediately after the
last character of the file.
answer given is -->d
it is little bit confusing me . i think ,answer may be 'a' as
"seek(long i)" method throws IoException and i know if a method
may throws Checked exception then it should be in try-catch block
or declared in throws clause of method.in this case there is no
try-catch block . so the code should not compile
d is correct if the code will be written in try-catch block.
pl. tell me the right answer
thanks in adv.
sunil