Abstract class error

+1 Arnab Banerjee · April 3, 2015
import java.util.*;
abstract  class Bank {

Scanner x = new Scanner(System.in);

abstract void deposite();
abstract void withdraw();
abstract void show();

class Savings extends Bank {
String name, ac_no;
double bal;
public static void main(String args[]){

Savings s = new Savings();


void createAccount(){
System.out.println("Enter your name ");
name = x.nextLine();
System.out.println("Enter your account no. ");
ac_no = x.nextLine();
System.out.println("Enter your initial balance ");
bal = x.nextDouble();
void deposite(double d){
System.out.println("Enter the amount you want to deposite");
d = x.nextDouble();
bal = bal +d;
void withdraw(double d){
System.out.println("Enter the amount you want to withdraw ");
d = x.nextDouble();
bal = bal-d;
void show(){
System.out.println("Your name is " +name);
System.out.println("Your account number is" +ac_no );

Post a Reply


Oldest  Newest  Rating
+1 Nicholas Eason · April 3, 2015

abstract void deposite(double d);
abstract void withdraw(double d);
abstract void show(double d);

I think that might work ^
+1 steven kitchener · April 4, 2015
When using abstract methods they must be the same in both the abstract class and the class that is extending it. 

In your code the method you are using is different to one you defined in the abstract class, differing parameters in this case.

As stated in Nicholas's answer you need to define the abstract methods as he has done. 

Also, if you use the annotation "@Override" on the line before you define the method in the extending class Java will inform you if you have an error and haven't defined it correctly. 
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator