Labels

Saturday, April 2, 2016

A program to show the concept of method overiding;

A program to show the concept of method overiding;

import java.io.*;
class A{
    private int a;
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    void input() throws IOException
    {
        System.out.print("Enter the value of A: ");
        a= Integer.parseInt(br.readLine());
    }
}
class B extends A{
    private int b;
    @Override
    void input() throws IOException
    {
        //super.input();
        System.out.print("Enter the value of B: ");
        b=Integer.parseInt(br.readLine());
    }
    void output()
    {
        System.out.println("A does not take any value.\nB: "+b);
    }
}
public class Q_2 {
    public static void main(String[] args) throws IOException
    {
        B b=new B();
        b.input();
        b.output();
    }
}



1 comment:

  1. Good Bro... bs beginner ke liye easy ni h.. 😉

    ReplyDelete