Saturday, 25 May 2013

Exception - 18 -

Given the following code

What code would be most likely for the body of the ioCall method


package net.dharmaraj;

import java.io.*;

public class Th
{
    public static void main(String argv[])
    {
        Th t = new Th();
        t.amethod();
    }

    public void amethod()
    {
        try
        {
            ioCall();
        }
        catch (IOException ioe)
        {
        }
    }
}


1) public void ioCall ()throws IOException{
 DataInputStream din = new DataInputStream(System.in);
 din.readChar();
 }
2) public void ioCall ()throw IOException{
 DataInputStream din = new DataInputStream(System.in);
 din.readChar();
 }
3) public void ioCall (){
 DataInputStream din = new DataInputStream(System.in);
 din.readChar();
 }
4) public void ioCall throws IOException(){
 DataInputStream din = new DataInputStream(System.in);
 din.readChar();
 }



Compile Out Put:--

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
The method ioCall() is undefined for the type Th

at net.dharmaraj.Th.amethod(Th.java:17)

at net.dharmaraj.Th.main(Th.java:10)

No comments:

Post a Comment