on 09-21-2006 8:47 AM
hello! I m a beginner in java..kindly help me to solve this question.
wat'll happen when u compile and run this code?
import java.io.*;
class Base{
public void amethod()throws FileNotFounfexception{}
}
public class ExcepDemo extends Base{
public static void main(String argv[]){
ExcepDemo e=new ExcepDemo();
}
public void amethod(){}
protected ExcepDemo(){
try{
DataInputStream din = new DataInputStream( System.in);
System.out.println("Pausing");
din.readByte();
System.out.println("Continuing");
this.amethod();
}catch(IOEception ioe){}
}
}
Options----
1. Compile time error caused by protected costructor
2. Compile time error caused by amethod not declaring Exception
3. Runtime error caused by amethod not declaring Exception
4. Compile and run with output of "Pausing" and "Continuing" after a key is hit.
Hello,
you've some syntax errors in your code like
<b>FileNotFounfexception == FileNotFoundException</b> or
<b>IOEception = IOException</b>
Here is the runable code:
import java.io.DataInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
class Base {
public void amethod() throws FileNotFoundException {
}
}
public class ExcepDemo extends Base {
public static void main(String argv[]) {
ExcepDemo e = new ExcepDemo();
}
public void amethod() {
}
protected ExcepDemo() {
try {
DataInputStream din = new DataInputStream(System.in);
System.out.println("Pausing");
din.readByte();
System.out.println("Continuing");
this.amethod();
} catch (IOException ioe) {
}
}
}
When you run this class in a command window the code line
din.readByte();
will wait until the user hit the Enter Key (CR/LF)
Hope this help
Torsten
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.